-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue 3037: Fix android compilation warnings #3086
issue 3037: Fix android compilation warnings #3086
Conversation
c945f27
to
b3eb6b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'd rather not have scripts hot patching dependencies, seems brittle.
Would you mind creating issues in the related projects? This also includes the one we already forked as we don't intend to diverge from original upstreams.
android/app/build.gradle
Outdated
@@ -117,7 +117,6 @@ def getVersionName = { -> | |||
|
|||
android { | |||
compileSdkVersion 24 | |||
buildToolsVersion "26.0.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the potential downside here? Looks like there was a reason for this difference in version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not essential to remove this as 26.0.2 is already the minimum supported version for Android Gradle Plugin 3.0.1. But there's no longer a need to specify it explicitly as the gradle plugin now specifies a default buildToolsVersion. Felt it was better to go with that, what do you think?
For the upstream projects these lines must be removed by updateUnforkedNodeModules.sh else we get errors like
WARNING: The specified Android SDK Build Tools version (25.0.3) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '25.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
@@ -21,13 +21,8 @@ | |||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | |||
|
|||
<!-- these permissions should be removed --> | |||
<!-- react-native-orientation adds an unnecessary permission; here we remove it --> | |||
<uses-permission android:name="android.permission.BLUETOOTH" tools:node="remove"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those not necessary anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like BLUETOOTH, WRITE_CONTACTS and RECORD_VIDEO were introduced by upstream projects sometime in the past, but these problems have now been fixed.
~/dev/status-react/node_modules $ grep -r BLUETOOTH * | grep AndroidManifest
~/dev/status-react/node_modules $ grep -r RECORD_VIDEO * | grep AndroidManifest
~/dev/status-react/node_modules $ grep -r WRITE_CONTACTS * | grep AndroidManifest
react-native-contacts/README.md:Add permissions to your `android/app/src/main/AndroidManifest.xml` file. Add only the permissions you need (i.e. if you don't need the _WRITE_CONTACTS_ permission then there's no need to add it).
~/dev/status-react/node_modules $
So there is no longer a need to remove them from AndroidManifest.xml, and trying to do so gives the warning.
<!-- react-native-camera --> | ||
<uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove"/> | ||
<uses-permission android:name="android.permission.RECORD_VIDEO" tools:node="remove"/> | ||
<!-- React Native unnecessary permissions (https://github.com/facebook/react-native/issues/5886) --> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is still necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like it's pulled in by instabug dependency:
~/dev/status-react/node_modules $ grep -r RECORD_AUDIO * | grep AndroidManifest
instabug-reactnative/android/build/intermediates/exploded-aar/com.instabug.library/instabug/3.4.0/AndroidManifest.xml: <uses-permission android:name="android.permission.RECORD_AUDIO" />
~/dev/status-react/node_modules $
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update the comment to add this info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Sure no problem, will start creating the issues. 😄 Note though there is precedent for patching this way, pkg-hacks.js already does this for the javascript files, creating the "hacking..." lines of output during scripts/setup. |
@pacamara Right this is part of It's ok if there are more warning, it's better to address those cleanly in upstream dependencies (or remove those completely) in the long run IMO. |
b94342f
to
0272507
Compare
@jeluard Ah I see, got it. Have:
To be clear, do you want |
I would say yes as it could hide stuff by mistake. It's ok if we have some warnings due to 3rd party deps. Thanks! |
0272507
to
84ec4eb
Compare
Roger that 😄
The build warnings from node_modules are back but do not include react-native-svg. |
@@ -116,8 +116,7 @@ def getVersionName = { -> | |||
} | |||
|
|||
android { | |||
compileSdkVersion 24 | |||
buildToolsVersion "26.0.2" | |||
compileSdkVersion 27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that impact our target mobile version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No there is no impact on the target version. 😄
From https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd (article by a dev at google):
It should be emphasized that changing your compileSdkVersion does not change runtime behavior...
Therefore it is strongly recommended that you always compile with the latest SDK.
@pacamara Awesome thanks for the changes! |
@jeluard You're welcome! 🍻 |
@jeluard Wondering if we want to hold off from asking upstream maintainers of node_modules to upgrade to gradle 3? It's a breaking change for freshly generated react native apps, unless manual changes are made to the generated code. See Perhaps we should wait until React Native itself is upgraded to gradle 3... what do you think? |
@pacamara Makes sense. Do you know if RN has planned such a change? |
@jeluard Can't find an open issue in react-native relating to a planned upgrade. Issue facebook/react-native#16536 suggests users upgrade gradle manually. Shall I close the issues in upstream node_modules projects? Or could ask maintainers to create a separate gradle 3 tag? |
@pacamara Sounds good! I guess we can wait now for more movement from RN. Maintainers are free to close your issues if they feel like it I guess? |
Building in Android Studio gives me 2 errors though:
But it doesn't build in |
84ec4eb
to
3f4ea46
Compare
@dmitryn Pushed another commit to fix the ABI problem. I was not experiencing it because my NDK version was out of date (now upgraded to v16):
@jeluard Sure! 🍻 |
Signed-off-by: Dmitry Novotochinov <[email protected]>
3f4ea46
to
6dd585f
Compare
@pacamara where do you see it? Did you get the tokens to your address? |
@dmitryn They just arrived a few minutes ago -- thank you! 🍻
Previously, the "pending maintainer confirmation" status was on the issue page and also on the SOB page. |
Fixes #3037 "Fix android compilation warnings"
Summary:
Remove nearly all android build warnings, using sed to modify build.gradle files of node_modules. For node_modules already forked by status there are separate PRs (see refs below).
4 warnings left:
The warnings (now silenced) about unnecessary removal of BLUETOOTH, WRITE_CONTACTS and RECORD_VIDEO permissions were leftovers from when some node_modules were adding these.
Testing notes:
Need to run scripts/setup again before building.
Steps to test:
status: ready