Compile ReactAndroid, fbjni error
Asked Answered
L

5

17

Downloaded from GitHub, to make moudle 'ReactAndroid', then:

Error:(687) Android NDK: Module reactnativejnifb depends on undefined modules: fbjni    
Error:(700) *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies)    
Error:Execution failed for task ':ReactAndroid:buildReactNdkLib'.
Process 'command '/Users/sumomokawaakira/Downloads/adt-bundle-mac-x86_64/sdk/ndk-bundle/ndk-build'' finished with non-zero exit value 2
Lubin answered 10/3, 2017 at 14:3 Comment(1)
Same problem here, did you ever find a solution? (I'm building RN 0.32.1 and seeing this)Higginson
E
7

I had this problem too. I think you can fix it by making sure you are using the precisely correct version of the Android NDK (android-ndk-r10e).

Also make sure that you set the environment variables and stuff done right.

(For what it's worth I'm stuck on later steps, but hopefully this should help you get passed this particular issue)

Erlina answered 17/3, 2017 at 6:21 Comment(4)
Its a long time ago, but I was able to get it work completely. Let me know where you got stuckSuspire
Where do we specify the Android NDK version? I'm confused.Eire
You have to change the environment ANDROID_NDK_HOME or some one like thisIdolater
I managed to compile reactnativejni, however when I try to load it I get "libreactnativejni.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)" So it looks like it was compiled as 32bit. Anybody same problem?Desjardins
P
2

You have to change your path to ANDROID_NDK to run gradle command locally.

export ANDROID_NDK=/Users/your_unix_name/android-ndk/android-ndk-r10e

In my case, I put NDK file at /Users/tomo/temp/android-ndk-r10e

so export ANDROID_NDK=/Users/tomo/temp/android-ndk-r10e

Or if you do not want to change ANDROID_NDK, you can update ReactAndroid/build.gradle

def findNdkBuildFullPath() {
    // we allow to provide full path to ndk-build tool
    if (hasProperty('ndk.command')) {
        return property('ndk.command')
    }
    // or just a path to the containing directory
    if (hasProperty('ndk.dir')) {
        def ndkDir = property('ndk.dir')
        return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
    }
    // ** Add below. should be before if (System.getenv('ANDROID_NDK') clause **
    Properties properties = new Properties()
    properties.load(project.rootProject.file('ReactAndroid/local.properties').newDataInputStream())
    if (properties.hasProperty('ndk.dir')) {
        def ndkDir = properties.getProperty('ndk.dir')
        return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
    }
    if (System.getenv('ANDROID_NDK') != null) {
        def ndkDir = System.getenv('ANDROID_NDK')
        return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
    }
    def ndkDir = android.hasProperty('plugin') ? android.plugin.ndkFolder :
            plugins.getPlugin('com.android.library').hasProperty('sdkHandler') ?
                    plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder() :
                    android.ndkDirectory.absolutePath
    if (ndkDir) {
        return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
    }
    return null
}

then update ReactAndroid/local.properties

ndk.dir=/Users/tomo/temp/android-ndk-r10e
sdk.dir=/Applications/sdk

and Run app from Android Studio

Pillion answered 19/10, 2017 at 17:29 Comment(1)
For me I added path for local.properties as ./local.properties as app's local.properties lies in ./android/local.properties, whereas ReactAndroid lies in ./node_modules/react-native/ReactAndroid and I am using local properties of appEtalon
C
2

for React Native 7.0

try either :

  1. rm -rf node_modules && yarn install (worked for me)

or

These steps:

  1. Close Android Studio
  2. Add android.disableAutomaticComponentCreation=true in android/gradle.properties
  3. Reopen project and build.
Coronary answered 13/1, 2023 at 10:33 Comment(0)
W
0

delete node modules , yarn.lock , invalidated caches in android studio or repair ide(all steps) ,package.lock remove ,

  • next run script "yarn install"
  • drag and drop android studio into android studio again ,
  • sync gradle files file and the error will be gone
Witcher answered 13/7, 2023 at 5:32 Comment(0)
P
0

Add below line in project level build.gradle file, 'buildscript' >>'ext' block

androidXCore = "1.0.2"

Pettish answered 31/1 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.