【问题标题】:My React Native android app is not running (Task :app:mergeDebugNativeLibs FAILED)我的 React Native Android 应用程序未运行(任务:app:mergeDebugNativeLibs 失败)
【发布时间】:2022-12-18 01:58:50
【问题描述】:

将 android gradle 更新为后,我无法运行本机 android 应用程序 “类路径‘com.android.tools.build:gradle:3.6.3’”并添加了“kotlin_version=‘1.6.0’”。

**我的安卓 --> build.gradle **

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 19
        compileSdkVersion = 31
        targetSdkVersion = 31
        googlePlayServicesAuthVersion = "16.0.1"
        kotlin_version='1.6.0' //add This change version with your installed kotlin version
    }
 dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" //add This

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        mavenCentral()
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

** 面临错误 **

此构建中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。 使用“--warning-mode all”来显示各个弃用警告。 见https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings 608 个可操作任务:2 个已执行,606 个是最新的 警告:将新 ns http://schemas.android.com/repository/android/common/02 映射到旧 ns http://schemas.android.com/repository/android/common/01 警告:将新 ns http://schemas.android.com/repository/android/generic/02 映射到旧 ns http://schemas.android.com/repository/android/generic/01

* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'lib/armeabi-v7a/libfbjni.so'

Screenshot of the error

我添加了 kotlin 版本并将 gradle 更改为“3.6.3”,我预计它会在添加 kotlin 和 gradle 版本更改后运行,但我无法打开应用程序。

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    将其添加到 android/build.gradle 文件的 allprojects 区域。

    def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
    
    allprojects {
        configurations.all {
            resolutionStrategy {
                // Remove this override in 0.65+, as a proper fix is included in react-native itself.
                force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2022-01-12
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2022-12-17
      • 2021-09-14
      • 1970-01-01
      • 1970-01-01
      • 2021-09-24
      相关资源
      最近更新 更多