android - 找不到 com.android.tools.build:gradle:4.1.3。在 Android Studio 中升级 gradle 后
问题描述
React native 0.64 app 从 4.0.x升级Android studio
到 4.1.3 后,我接受了将 gradle 升级到 4.1.3 的建议,并按照说明进行升级。但是 React Native 应用程序重建会引发错误:
Could not find com.android.tools.build:gradle:4.1.3.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.3/gradle-4.1.3.pom
点击以上https://jcenter.binatray.com/com/...
登陆页面Forbidden
。是错误的原因吗?
我还将 gradle 版本gradle-wrapper.properties
从 6.7 更改为 6.8.3:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
在 中build.gradle
,还有:
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")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
maven { url 'https://maven.google.com'
name 'Google'
}
}
同步项目抛出相同的错误。
更新:build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:4.1.3')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
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")
}
jcenter()
maven { url 'https://www.jitpack.io' }
maven { url 'https://maven.google.com' } //for react-native-image-crop-picker
mavenCentral()
}
}
解决方案
推荐阅读
- php - PHP exec命令不适用于ImageMagick
- python - 如何遍历数据框,添加 3 个特定行,用它们的总和替换这 3 行,然后每 57 行重复一次?
- python - 我想用python开发一个谈话程序
- javascript - 将对象的属性和值提取到新对象中
- html - 文档为空( lxml.etree.ParserError: Document is empty )
- python - 序列上的迭代器
- excel - Excel 无法将宏分配给按钮
- android - 如何仅在活动上动画淡出
- reactjs - Material UI 如何连接步进器线并更改连接器的颜色
- java - 根据条件从下一行中选择一个项目