【React Native(找不到com.android.tools.build:gradle:2.2.3)】胸怀万里世界, 放眼无限未来。这篇文章主要讲述React Native:找不到com.android.tools.build:gradle:2.2.3相关的知识,希望能为你提供帮助。
我正在使用本机做一个android应用程序,这是我得到的错误:
FAILURE: Build failed with an exception.* What went wrong: A problem occurred configuring project ':react-native-fetch-blob'. > Could not resolve all artifacts for configuration ':react-native-fetch-blob:classpath'. > Could not find com.android.tools.build:gradle:2.2.3. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar Required by: project :react-native-fetch-blob
我也收到以下警告:
> Configure project :app WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html WARNING: The specified Android SDK Build Tools version (26.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1. Android SDK Build Tools 28.0.3 will be used. To suppress this warning, remove "buildToolsVersion '26.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools. registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)> Configure project :react-native-android-location-services-dialog-box WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html WARNING: The specified Android SDK Build Tools version (25.0.2) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1. Android SDK Build Tools 28.0.3 will be used. To suppress this warning, remove "buildToolsVersion '25.0.2'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
这是我的build.gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.2.1'// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:3.0.0' } }allprojects { repositories { google() mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" }// jitpack repo is necessary to fetch ucrop dependency maven { url "https://jitpack.io" } } }
这是我的gradle包装器分发URL:
distributionUrl = HTTPS://services.gradle.org/distributions/gradle-4.6-all.zip我尝试更改不同存储库的顺序,但仍然得到相同的错误。
答案似乎从jcenter存储库中删除了com.android.tools.build:gradle:2.2.3。
尝试将此代码添加到顶级build.gradle文件中:
subprojects {project ->
if (project.name.contains('react-native-fetch-blob')) {
buildscript {
repositories {
maven { url "https://dl.bintray.com/android/android-tools/"}
}
}
}
}
另一答案正如google issuetracker:https://issuetracker.google.com/issues/120759347#comment44所见的解决方法
查看错误日志:
您仍在为您的项目
- 出了什么问题:配置项目':react-native-fetch-blob'时出现问题。无法解析配置':react-native-fetch-blob:classpath'的所有工件。找不到com.android.tools.build:gradle:2.2.3。
:react-native-fetch-blob
搜索AGP 2.2.3。对于使用Android Gradle Plugin较低版本的React Native或CordovaLib项目,例如2.2.3,您可以尝试用以下
google()
样式替换maven
,并添加android工具解决方法。因此,修改build.gradle
和buildscripts
的顶级allprojects
文件,如下所示:buildscripts {
repositories {// below is the workaround for android tools
maven {
artifactUrls "https://dl.bintray.com/android/android-tools/"
url "https://jcenter.bintray.com"
}
maven {
url "https://maven.google.com"
}// ...
jcenter()}
}allprojects {
repositories {// below is the workaround for android tools
maven {
artifactUrls "https://dl.bintray.com/android/android-tools/"
url "https://jcenter.bintray.com"
}
maven {
url "https://maven.google.com"
}// ...
jcenter()}
}
清理项目,然后执行新的同步。
- 尝试“文件” - > “使缓存无效/重新启动...”
- 尝试清理项目根目录下的
.gradle
和.idea
目录。
- https://stackoverflow.com/a/51151050/8034839
- https://stackoverflow.com/a/51354236/8034839
警告:配置'compile'已过时,已被'implementation'和'api'取代。因为您使用的是AGP(Android Gradle Plugin 3.2.1),所以构建配置
compile
已更改为implementation
和api
。只需用compile
或implementation
替换所有的api
就会让这个警告消失。请参阅:https://developer.android.com/studio/build/dependencies#dependency_configurations了解更多详情。警告:指定的Android SDK Build Tools版本(25.0.2)将被忽略,因为它低于Android Gradle Plugin 3.2.1的最低支持版本(28.0.3)。将使用Android SDK Build Tools 28.0.3。要取消此警告,请从build.gradle文件中删除“buildToolsVersion '25 .0.2'”,因为每个版本的Android Gradle Plugin现在都有一个默认版本的构建工具。此警告仅供您参考,您可以忽略它或从
buildToolsVersion '25.0.2'
文件中删除build.gradle
以禁止此警告。推荐阅读
- application.jar中没有主要清单属性
- Android(如何让gradle让特定的依赖关系脱机而其他人在线())
- 从java模块引用android库
- 无法解析项目(Android库和Java库模块依赖项)
- 我安装了Android Studio,但我无法通过命令行访问gradle
- 使用Android Studio 3.1和build构建项目时出错(gradle 3.1.0)
- Gradle android无法找到符号Context
- Android Studio 3.1 gradle build抛出java.util.zip.ZipException
- Android Studio 3.1陷入“Building *** Gradle项目信息”