Skip to content
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

Merged
merged 1 commit into from
Feb 1, 2018

Conversation

pacamara
Copy link
Contributor

@pacamara pacamara commented Jan 18, 2018

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:

  • "Task.leftShift(Closure) method has been deprecated" -- from node_modules/realm/android/build.gradle. Have tested fix for this, but cannot use sed as fix is multiline. Should we fork realm or leave this one?
  • "registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)" -- from one of the plugins, not from status code.
  • "warning: the transform cache was reset" -- from XCode build, not android.
  • "Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead." -- stackoverflow says could also be from a plugin.

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:

  • scripts/setup
  • build as normal
  • observe log for build warnings

status: ready

Copy link
Contributor

@jeluard jeluard left a 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.

@@ -117,7 +117,6 @@ def getVersionName = { ->

android {
compileSdkVersion 24
buildToolsVersion "26.0.2"
Copy link
Contributor

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?

Copy link
Contributor Author

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"/>
Copy link
Contributor

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?

Copy link
Contributor Author

@pacamara pacamara Jan 19, 2018

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"/>
Copy link
Contributor

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?

Copy link
Contributor Author

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 $ 

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@pacamara
Copy link
Contributor Author

I'd rather not have scripts hot patching dependencies, seems brittle.
Would you mind creating issues in the related projects?

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.

@jeluard
Copy link
Contributor

jeluard commented Jan 19, 2018

@pacamara Right this is part of rn-nodeify but I'd rather move in the direction of removing those.

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.

@pacamara pacamara force-pushed the develop_issue3037_fixWarnings branch 2 times, most recently from b94342f to 0272507 Compare January 19, 2018 17:16
@pacamara
Copy link
Contributor Author

pacamara commented Jan 19, 2018

@jeluard Ah I see, got it. Have:

  • created all the issues in upstream projects.
  • added the comment about RECORD_AUDIO.
  • also changed from api to implementation for the dependencies directly used by status-react, because api is only recommended for the dependencies used by library projects (such as the upstream node_modules).

To be clear, do you want updateUnforkedNodeModules.sh removed from this PR?

@jeluard
Copy link
Contributor

jeluard commented Jan 19, 2018

To be clear, do you want updateUnforkedNodeModules.sh removed from this PR?

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!

@pacamara pacamara force-pushed the develop_issue3037_fixWarnings branch from 0272507 to 84ec4eb Compare January 19, 2018 20:26
@pacamara
Copy link
Contributor Author

pacamara commented Jan 19, 2018

Roger that 😄
Have:

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@jeluard
Copy link
Contributor

jeluard commented Jan 20, 2018

@pacamara Awesome thanks for the changes!

@pacamara
Copy link
Contributor Author

@jeluard You're welcome! 🍻

@pacamara
Copy link
Contributor Author

@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
software-mansion/react-native-svg#581

Perhaps we should wait until React Native itself is upgraded to gradle 3... what do you think?

@jeluard
Copy link
Contributor

jeluard commented Jan 22, 2018

@pacamara Makes sense. Do you know if RN has planned such a change?

@pacamara
Copy link
Contributor Author

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?

@jeluard
Copy link
Contributor

jeluard commented Jan 23, 2018

@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?

@jeluard jeluard requested review from dmitryn and yenda January 23, 2018 07:12
@dmitryn
Copy link
Contributor

dmitryn commented Jan 23, 2018

run-android works fine for me (except warnings coming from node_modules which were discussed above).

Building in Android Studio gives me 2 errors though:

/Users/trybeee/Library/Android/sdk/ndk-bundle/build/core/setup-app.mk
Error:(81) Android NDK: Application targets deprecated ABI(s): mips64 armeabi mips    
Error:(82) Android NDK: Support for these ABIs will be removed in a future NDK release.    

But it doesn't build in develop branch either.

@pacamara pacamara force-pushed the develop_issue3037_fixWarnings branch from 84ec4eb to 3f4ea46 Compare January 24, 2018 01:39
@pacamara
Copy link
Contributor Author

@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):

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?

@jeluard Sure! 🍻

@dmitryn dmitryn force-pushed the develop_issue3037_fixWarnings branch from 3f4ea46 to 6dd585f Compare February 1, 2018 12:27
@dmitryn dmitryn merged commit 6dd585f into status-im:develop Feb 1, 2018
@pacamara
Copy link
Contributor Author

pacamara commented Feb 2, 2018

Hi @jeluard @dmitryn , it's still showing as pending maintainer confirmation, could you confirm the payout please?

@dmitryn
Copy link
Contributor

dmitryn commented Feb 2, 2018

@pacamara where do you see it? Did you get the tokens to your address?

@pacamara
Copy link
Contributor Author

pacamara commented Feb 2, 2018

@dmitryn They just arrived a few minutes ago -- thank you! 🍻

where do you see it?

Previously, the "pending maintainer confirmation" status was on the issue page and also on the SOB page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix android compilation warnings
4 participants