编译ReactAndroid,fbjni错误

问题描述 投票:0回答:5

从 GitHub 下载,制作 moudle 'ReactAndroid',然后:

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
github compiler-errors react-native
5个回答
7
投票

我也遇到这个问题了。我认为您可以通过确保使用准确正确的 Android NDK 版本来修复此问题 (

android-ndk-r10e
)。

还要确保设置环境变量并正确完成工作。

(对于它的价值,我坚持后面的步骤,但希望这应该帮助您解决这个特定问题)


2
投票

您必须更改 ANDROID_NDK 的路径才能在本地运行 gradle 命令。

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

就我而言,我将 NDK 文件放在

/Users/tomo/temp/android-ndk-r10e

所以 导出 ANDROID_NDK=/Users/tomo/temp/android-ndk-r10e

或者如果您不想更改ANDROID_NDK,您可以更新

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
}

然后更新

ReactAndroid/local.properties

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

并从 Android Studio 运行应用程序


2
投票

适用于 React Native 7.0

尝试一下:

  1. rm -rf node_modules && 纱线安装(对我有用)

这些步骤:

  1. 关闭Android Studio
  2. 在 android/gradle.properties 中添加 android.disableAutomaticComponentCreation=true
  3. 重新打开项目并构建。

0
投票

删除节点模块,yarn.lock,android studio中无效的缓存或修复ide(所有步骤),package.lock删除,

  • 接下来运行脚本“yarn install”
  • 再次将 android studio 拖放到 android studio 中,
  • 同步 gradle 文件 错误就会消失

0
投票

在项目级别 build.gradle 文件中添加以下行,“buildscript”>>“ext”块

androidXCore =“1.0.2”

© www.soinside.com 2019 - 2024. All rights reserved.