我正在使用本地本机制作一个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包装器分发网址:
distributionUrl = https://services.gradle.org/distributions/gradle-4.6-all.zip
我尝试更改不同存储库的顺序,但仍然遇到相同的错误。
答案 0 :(得分:5)
似乎com.android.tools.build:gradle:2.2.3已从jcenter存储库中删除。
尝试将此代码添加到顶级build.gradle文件中:
subprojects {project ->
if (project.name.contains('react-native-fetch-blob')) {
buildscript {
repositories {
maven { url "https://dl.bintray.com/android/android-tools/" }
}
}
}
}
答案 1 :(得分:1)
从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
目录。请参阅以下参考资料:
警告:
警告:配置'compile'已过时,并已由'implementation'和'api'代替。
由于您使用的是AGP( A ndroid G radle P lugin 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插件现在都具有默认版本的构建工具。
此警告仅供参考,您可以忽略该警告或从buildToolsVersion '25.0.2'
文件中删除build.gradle
以禁止显示此警告。