React native 近期Android 无法编译的问题解决

 程序包com.facebook.react.bridge不存在

 在android/build.gradle下添加如下代码:

exclusiveContent {
    // We get React Native's Android binaries exclusively through npm,
    // from a local Maven repo inside node_modules/react-native/.
    // (The use of exclusiveContent prevents looking elsewhere like Maven Central
    // and potentially getting a wrong version.)
    filter {
        includeGroup "com.facebook.react"
    }
    forRepository {
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

我解决时对应的gradle版本

 根本原因是Jcenter关闭服务

Android build failed: 'Failed to list versions for com.facebook.react:react-native.' · Issue #35136 · facebook/react-native · GitHub

Jcenter服务即将关闭,改用mavenCentral - 知乎

Could not resolve com.facebook.react:react-native:+

20230705更新:

注意如果出现下列异常,请检查gradle版本有没有都设置好 (特别是gradle-wrapper.properties这个文件)

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException:

例如我在工程的build中

dependencies {
    classpath 'com.android.tools.build:gradle:4.1.0'
}

对应到gradle-wrapper.properties中 是设置6.5版本

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

猜你喜欢

转载自blog.csdn.net/loveseal518/article/details/127745114
今日推荐