8

I am trying to run the UIExplorer project on Ubuntu 14.04. I have installed SDK and NDK. I am able to run usual projects of react native(the one's I create), but not the Examples from Official Repo.

export ANDROID_NDK=/home/bozzmob/android-ndk-r10e/

I am getting the following error-

Execution failed for task ':ReactAndroid:buildReactNdkLib'.

Process 'command '/home/bozzmob/android-ndk-r10e/ndk-build'' finished with non-zero exit value 2

Logs look like-

root@purvotara:~/ReactJS/native/react-native# ./gradlew :Examples:UIExplorer:android:app:installDebug
.
.
.
:ReactAndroid:buildReactNdkLib
make: Entering directory `/home/bozzmob/ReactJS/native/react-native/ReactAndroid/src/main/jni/react/jni'
[armeabi-v7a] Compile++ thumb: reactnativejni <= OnLoad.cpp
[armeabi-v7a] SharedLibrary : libfb.so
[armeabi-v7a] SharedLibrary : libglog.so
[armeabi-v7a] StaticLibrary : libdouble-conversion.a
BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-> androideabi/4.8/liblto_plugin.so: file too short

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short

BFD: /home/bozzmob/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.8/liblto_plugin.so: file too short

[armeabi-v7a] Prebuilt : libjsc.so <= /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/third-party-ndk/jsc/jni/armeabi-v7a/
[armeabi-v7a] Compile++ thumb: reactnative <= Bridge.cpp
[armeabi-v7a] Compile++ thumb: reactnative <= Value.cpp
[armeabi-v7a] Compile++ thumb: reactnative <= JSCHelpers.cpp
[armeabi-v7a] Compile++ thumb: reactnative <= JSCExecutor.cpp
[armeabi-v7a] Install : libjsc.so => /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libjsc.so
[armeabi-v7a] Install : libgnustl_shared.so => /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libgnustl_shared.so
make: *** [/home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libgnustl_shared.so] Error 1
make: *** Deleting file /home/bozzmob/ReactJS/native/react-native/ReactAndroid/build/react-ndk/all/armeabi-v7a/libgnustl_shared.so' make: *** Waiting for unfinished jobs.... make: Leaving directory/home/bozzmob/ReactJS/native/react-native/ReactAndroid/src/main/jni/react/jni'
:ReactAndroid:buildReactNdkLib FAILED

FAILURE: Build failed with an exception.

    What went wrong:
    Execution failed for task ':ReactAndroid:buildReactNdkLib'.

        Process 'command '/home/bozzmob/android-ndk-r10e/ndk-build'' finished with non-zero exit value 2

    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: 1 mins 34.069 secs

Please let me know what I am doing wrong?

bozzmob
  • 12,364
  • 16
  • 50
  • 73

2 Answers2

1

Seems like you're having problems with compiling native (c++) sources of react-native android. In order to start new project you should not be required to do that (no NDK setup is required) and therefore you can just try creating sample project with react-native init (see this for instructions). After that you can just copy sample app JS files to your newly created project.

If you'd still like to build framework code from source, I'd need some more details in order to help you. I'd suggest enabling verbose mode for ndk-build, then you can get back here with the output. In order to enable verbose mode you'd need to modify this file: ReactAndroid/build.gradle and add 'V=1' to args so that the code fragment I linked to looks like this:

    commandLine getNdkBuildFullPath(),
        'NDK_PROJECT_PATH=null',
        'V=1',
        "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
        'NDK_OUT=' + temporaryDir,
kzzzf
  • 2,614
  • 1
  • 16
  • 7
  • Thanks a lot for your reply. I did what you said i.e., 'V=1' and here is my output log- https://gist.github.com/bozzmob/3cec8388bc7d75895160 or http://pastebin.com/VesSeBts – bozzmob Nov 26 '15 at 18:52
  • I also tried to create a new project and copy files and trying to run. It unfortunately didn't work out well. It doesn't run and throws up same error. But, if the project is created and I write my code in there, it works fine. – bozzmob Nov 26 '15 at 18:57
  • 1
    So looks like ndk-build is doing sth werid and not copying `libgnustl_shared.so` properly to `react-native/ReactAndroid/build/tmp/buildReactNdkLib/local/armeabi-v7a/libgnustl_shared.so` can you try doing it manually? You should find it under your android ndk distribution folder at `./sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/thumb/libgnustl_shared.so` – kzzzf Nov 27 '15 at 11:20
  • WOW! It worked like charm! Thanks a lot @kzzzf I was trying this from a month and it was failing due to multiple issues. Finally its fixed. GIving you Bounty points for your patience and clear responses. – bozzmob Nov 27 '15 at 16:53
  • Glad it helped @bozzmob but note that this is just a workaround. Every time you clear the build you'd need to copy those files again. I'd recommend asking a question with `android-ndk` tag (or maybe someone have already answered similar one) on what could be the possible reasons for `ndk-build` not copying those files automatically as a part of the build script. Everything seems to be setup just fine and it works correctly for many people – kzzzf Nov 30 '15 at 08:54
  • @kzzzf i tried to do the same as you recommended above but i think there's problem with my toolchain. I tried but i can't figure out what to do here to install the toolchain that UIExplorer requires to build. it requires i think 4.8 and i have 4.9. Here's my log output - https://gist.github.com/vinaynb/13fd43a0d96d30ee0feabe491b7e7c84 Can you help ? – Vinay Aug 21 '16 at 14:24
0

I also encountered same build error and found solution from this post. You must use the Android NDK r10e instead of the latest one (r11).

Community
  • 1
  • 1
yoarcher
  • 5
  • 1
  • 3