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

React Native apps fail to build since NDK update to r17 (due to missing mipsel-linux-android-4.9 toolchain files) #700

Closed
sunweiyang opened this issue May 17, 2018 · 22 comments

Comments

@sunweiyang
Copy link

sunweiyang commented May 17, 2018

Description

Android React Native apps have not been able to successfully build since we updated NDK to r17. The build error shows this:

> A problem occurred starting process 'command '/Users/myuser/Library/Android/sdk/ndk-bundle/toolchains/mipsel-linux-android-4.9/prebuilt/darwin-x86_64/bin/mipsel-linux-android-strip''

To work around this, our team had to manually replace the bare NDK r17 ~/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/ and ~/Library/Android/sdk/ndk-bundle/toolchains/mipsel-linux-android-4.9/ directories with those of the old NDK r16. Almost all files that were once in these 2 directories bacvk in NDK r16 are completely gone in the new NDK r17.

Steps to reproduce:

  1. Create a new React Native app called TestApp using the following commands on macOS:
brew install node
brew install watchman
npm install -g react-native-cli
react-native init TestApp

(Use this link if issues arise with Android dev environment: https://facebook.github.io/react-native/docs/getting-started.html)
2. Open an Android emulator and build the Android app using react-native run-android
3. Observe the following build error:

:app:transformNative_libsWithStripDebugSymbolForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformNative_libsWithStripDebugSymbolForDebug'.
> A problem occurred starting process 'command '/Users/myuser/Library/Android/sdk/ndk-bundle/toolchains/mipsel-linux-android-4.9/prebuilt/darwin-x86_64/bin/mipsel-linux-android-strip''

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 15.318 secs
@sunweiyang sunweiyang changed the title React Native React Native apps fail to build since NDK update to r17 (due to missing mipsel-linux-android-4.9 toolchain files) May 17, 2018
@stephenhines
Copy link
Collaborator

Mips is no longer officially supported by the NDK, so you can get past this by removing those configurations from your default build. See the announcements for r17 on https://developer.android.com/ndk/downloads/revision_history.

@kneth
Copy link

kneth commented May 17, 2018

@sunweiyang
Copy link
Author

@kneth The RN codebase includes support for armeabi-v7a, which uses the mipsel-linux-android-4.9 toolchain.

@stephenhines
Copy link
Collaborator

@sunweiyang I'm confused. armeabi-v7a is the ABI for 32-bit ARM and mipsel* is for 32-bit MIPS targets. There are no mipsel* tools that should be used for any part of an ARM build.

@steverob
Copy link

Any updates @sunweiyang?

@krystiansliwa
Copy link

@sunweiyang I tried to use your workaround on AppCenter but it doesn't work

@sunweiyang
Copy link
Author

@kneth @stephenhines @steverob Apologies for the confusion -- the issue seems to center around the use of AppCenter (as described in microsoft/appcenter-sdk-react-native#317).

@krystiansliwa, it looks like you were able to get the clarification you needed in microsoft/appcenter-sdk-react-native#317 as well -- glad to see it.

@alexcohn
Copy link

This problem haunts not only React Native, but many other users who download the latest NDK and don't update their Gradle plugin. This happens regardless of abiFIlters, and even for people who only have 3ʳᵈ party prebuilt native libraries.

The workaround is actually trivial, it's a pity it was not included in r17:

Add two dummy executable files /mipsel-linux-android-4.9/prebuilt/…/bin/mipsel-linux-android-strip and mips64el-linux-android-4.9/prebuilt/…/bin/mips64el-linux-android-strip.

@enh
Copy link
Contributor

enh commented May 22, 2018

i'm a bit confused because i thought this was the issue @rprichard found in the betas, and that that was the workaround that's in r17?

@rprichard
Copy link
Collaborator

r17 has various mostly-empty directories, but no fake strip binaries:

  • toolchains/mipsel-linux-android-4.9/prebuilt/${HOST_OS}
  • toolchains/mips64el-linux-android-4.9/prebuilt/${HOST_OS}
  • platforms/android-14/arch-mips
  • platforms/android-21/arch-mips64

I'm wondering what version of the Gradle plugin is having issues here.

@enh
Copy link
Contributor

enh commented May 22, 2018

yeah, microsoft/appcenter-sdk-react-native#317 just says "3.1.2 doesn't have this problem". hopefully @alexcohn's comment means he's seen this himself and can tell us what gradle version it was with?

@alexcohn
Copy link

alexcohn commented May 23, 2018

For me, 3.0.1 failed on this.

I see many complaints on SO, and not everybody takes easily the advice "just upgrade your gradle plugin to 3.1.2" because this also means that they need to upgrade gradle to at least gradle-4.4 and then fix something else…

The difference is that the files build.gradle and gradle/wrapper/gradle-wrapper.properties are under source control, and people often pull them from outdated repositories. At the same time, their Android Studio automatically installs NDK r.17 without warning them that they need now to upgrade all their modules to latest gradle plugin.

And it does work sometimes. Only the unhappy circumstance that one of their dependencies has some mips native library packaged breaks the build.

@enh
Copy link
Contributor

enh commented May 23, 2018

@rprichard --- is that the difference between the bug(s) we found and this one that we didn't? we didn't test a project that didn't have mips configured but did have a mips prebuilt? (if i understand correctly what alexcohn is saying.)

@rprichard
Copy link
Collaborator

That sounds plausible. I'll do some testing.

I created a new React Native project today using instructions at https://facebook.github.io/react-native/docs/getting-started.html. Here's what I've noticed so far:

  • The React Native project has a Gradle project in an android subdir.
  • The new Gradle project uses Gradle plugin version 2.2.3.
  • The app module's build.gradle file specifies both abiFilters and ABI splits. Both explicitly list the armeabi-v7a and x86 ABIs. It looks like the ABI splits setting is off by default.
  • gradle.properties specifies android.useDeprecatedNdk=true.
  • The project builds with NDK r17 installed, or with no NDK installed.
  • Shared libraries from ./node_modules/react-native/android/com/facebook/react/react-native/0.55.4/react-native-0.55.4.aar are bundled with the app's apks. The aar file only has libraries for armeabi-v7a and x86. It contains libgnustl_shared.so.

@rprichard
Copy link
Collaborator

I can reproduce a problem with Studio 3.0.1 and NDK r17:

  • Create a new Android project.
  • Add this line to app's dependencies: implementation 'com.github.barteksc:pdfium-android:1.8.2' [Link]. The https://github.com/wonday/react-native-pdf project indirectly uses pdfium-android, and pdfium-android-1.8.2.aar has solibs for armeabi and mips.)

gradlew assembleDebug fails with:

* What went wrong:
Execution failed for task ':app:transformNativeLibsWithStripDebugSymbolForDebug'.
> A problem occurred starting process 'command '/usr/local/google/home/rprichard/studio-3.0/android-sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/bin/mips64el-linux-android-strip''

Notes:

  • abiFilters doesn't matter.
  • If I uninstall the NDK, the build quietly succeeds (with plugin 3.0.1 or plugin 3.1.2).
  • With plugin version 3.1.2, if NDK r17 is installed, then the build succeeds with warnings:
    > Task :app:transformNativeLibsWithStripDebugSymbolForDebug 
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi/libjniPdfium.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi/libmodpdfium.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi/libmodpng.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi/libmodft2.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/mips/libjniPdfium.so' due to missing strip tool for ABI 'MIPS'. Packaging it as is.
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/mips/libmodpdfium.so' due to missing strip tool for ABI 'MIPS'. Packaging it as is.
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/mips/libmodpng.so' due to missing strip tool for ABI 'MIPS'. Packaging it as is.
    Unable to strip library '/usr/local/google/home/rprichard/PdfTestApp/app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/mips/libmodft2.so' due to missing strip tool for ABI 'MIPS'. Packaging it as is.
    
    
    BUILD SUCCESSFUL in 5s
    

@alexcohn
Copy link

quite predictably, the complaints and weird workarounds for the missing …-strip executables are spreading like bushfire

@DanAlbert
Copy link
Member

The problem is that a given gradle plugin does not support every version of the NDK and the NDK is being updated without the gradle plugin. Studio absolutely needs to do a better job of helping users not point the gun at their foot, but fundamentally the configuration causing this bug needs to be avoided.

I've summarized @alexcohn's comments above into a couple of bugs for Studio:

http://b/80431718 Studio pins gradle plugin revisions but not NDK revisions, even though they are related
http://b/80431288 Studio does not warn users when their NDK version is incompatible with their gradle plugin

It sounds like these two issues are at the crux of the problem. Migrating to newer build tools during a project's development is hard, and Studio/gradle are making it hard to avoid that process.

All that said, the 3.1 build tools are now in the stable channel and do not have this problem, so the fix for this is to update to the latest version of the build tools. If it's not a good time to do that for your project, you have two options:

The first option is to apply this workaround from Stack Overflow:

// In build.gradle
packagingOptions{
    doNotStrip '*/mips/*.so'
    doNotStrip '*/mips64/*.so'
}

The second is to continue using NDK r16b with the 3.0 build tools. Download the previous version of the NDK from https://developer.android.com/ndk/downloads/, extract it somewhere, and change the ndk.dir variable in local.properties file to point there rather than into the SDK install path.

@fungilation
Copy link

@DanAlbert 's work around doesn't work for me. Either I put it inside a subproject{} and get Could not find method doNotStrip() for arguments [*/mips/*.so] on object of type com.android.build.gradle.LibraryExtension.

Or in base build.gradle: > A problem occurred starting process 'command '~/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin/mips64el-linux-android-strip''

@sroycode
Copy link

Very crude quick-fix

mkdir ~/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin
touch ~/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin/mips64el-linux-android-strip

@Kennytian
Copy link

android/build.gradle

- classpath 'com.android.tools.build:gradle:2.2.3'
+ classpath 'com.android.tools.build:gradle:2.3.3'

android/gradle/wrapper/gradle-wrapper.properties

- distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip

@donnie-jp
Copy link

I had a similar issue but with aarch64-linux-android-strip.

I followed #700 (comment) but still got a build error A problem occurred starting process <path>/aarch64-linux-android-strip.

I also had to do chmod +x on the created file to make it executable. After that change my build succeeded with a warning Unable to strip library '<path>/libicu_common.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.

@rishivishwa

This comment was marked as off-topic.

@android android locked as resolved and limited conversation to collaborators May 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests