【发布时间】:2021-03-30 20:56:16
【问题描述】:
最近 Android Studio 好心提供升级到 gradle 6.5。 我很天真:我点击了是,然后发生了新的升级,现在每次我构建时都会收到类似于以下内容的错误:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
> A problem occurred configuring project ':react-native-fs'.
> Could not resolve all artifacts for configuration ':react-native-fs:classpath'.
> Could not find com.android.tools.build:gradle:4.1.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.1/gradle-4.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :react-native-fs
我的android/build.gradle 文件有这些行:
buildscript {
repositories {
mavenLocal()
google()
jcenter()
maven { url "$rootDir/../node_modules/react-native/android" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}
所以生活对我的项目有好处,但对很多模块来说却不是这样:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
}
为了解决这个问题,我需要添加google() 存储库。
...但我不喜欢手动编辑 node_modules/ 文件夹下的任何文件,因为任何新安装都会破坏它们。
有没有办法解决这个问题?
【问题讨论】:
-
你找到解决办法了吗?
-
+ Yogesh Lolusare:不抱歉。但在花了 50 多个小时修复各种依赖问题后,我开始意识到 React Native 对于长期项目来说是一个真正的烂摊子。
-
删除 node_modules 文件夹并在 Android Studio 中运行 yarn install 或 npm install 重新打开项目,就这样解决了我的问题
标签: react-native android-studio gradle android-gradle-plugin