Android Studio 自2022年11月4日起发生Android构建故障[内部修复]

wooyq4lh  于 2022-11-16  发布在  Android
关注(0)|答案(3)|浏览(271)

生成错误类似于:

错误:命令失败:gradlew.bat应用程序:安装调试-PreactNativeDevServer端口=8081
失败:生成失败,出现异常.

  • 问题:设定根项目'My Project'时发生问题。无法判断Null的相依性。无法解析组态':classpath'的所有工作相依性。

无法解析com。facebook。react:react-native:+。要求者:project:找不到com.facebook.react的匹配变体:react-native:0.71.0-rc.0。使用者配置为查找与Java 11兼容的库的运行时,该库打包为jar,其依赖项在外部声明,以及值为“7.3.3”的属性“org.gradle.plugin.api-version”

6yjfywim

6yjfywim1#

在项目级build.gradle中更新以下内容:

allprojects {
    repositories {
       exclusiveContent {
           filter {
               includeGroup "com.facebook.react"
           }
           forRepository {
               maven {
                   url "$rootDir/../node_modules/react-native/android"
               }
           }
       }
        // ...
    }
}

对我很有效

368yc8dk

368yc8dk2#

内部固定
几天来我们一直面临的React式原生问题的解决步骤。

1.后藤package.json并将react-native版本升级到0.64.4.(或者GitHub线程上支持的任何版本)
1.运行Yarn安装。
1.现在的cd android
1../gradlew清除
1.光盘..

  1. yarn android(现在您项目将正确执行)
    注:此问题是由于react native的新版本(11月4日)而发生的,在此附上参考链接。

网址:https://github.com/facebook/react-native/issues/35210

(if你遇到任何问题,让我知道,我会帮助你解决相同的。)

3xiyfsfu

3xiyfsfu3#

此修复程序有效:
失败原因:Android的构建失败是由于将React Native版本0.71.0-rc 0发布到Maven,因此当gradle同步时,它会选择react-native的0.71.0-rc 0版本,而不是您当前的react-native版本。

在不升级react-native版本的情况下,通过在build.gradle中添加此功能,使其工作**(启用或不启用爱马仕,沿着flipper)**

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"
                }
            }
        }

最后一个代码片段如下所示

allprojects {
    repositories {
        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"
                }
            }
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")

在此修复后,Gradle将进行清理和重建。然后您可以成功地在本地运行Android。
此修复程序将应用exclusiveContent解析规则,强制React Native Android库的解析使用node_modules内部的解析
如果您不想进行此修复,可以将项目的react原生版本更新为react原生补丁版本,如此处所述
https://github.com/facebook/react-native/issues/35210

相关问题