无法构建android项目它显示错误 [英] can't build android project it shows error
问题描述
project gradle
project gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.arun4fms.efix"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.chabbal:slidingdotsplash:1.0.2'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
错误:配置根项目'webapp'时出现问题。
Error:A problem occurred configuring root project 'webapp'.
无法解析配置':classpath'的所有依赖项。
找不到com.android.tools.build:gradle:3.0.0-alpha3。
在以下位置搜索:
文件:/ C:/ Program Files / Android / Android Studio / gradle / m2repository / com / android / tools / build / gradle / 3.0.0-alpha3 / gradle- 3.0.0-alpha3.pom
文件:/ C:/ Program Files / Android / Android Studio / gradle / m2repository / com / android / tools / build / gradle / 3.0.0-alpha3 / gradle-3.0.0 -alpha3.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
< a href =https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar =nofollow noreferrer> https:/ /jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
要求:
项目:
Could not resolve all dependencies for configuration ':classpath'. Could not find com.android.tools.build:gradle:3.0.0-alpha3. Searched in the following locations: file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar Required by: project :
推荐答案
已经回答此处:
Google有新的maven repo,所以这可能是原因。
Google have new maven repo, so it could be the reason.
https://android-developers.googleblog.com/2017/05/android-studio-3-0-canary1.html
部分 Google的Maven资源库
https://developer.android.com/studio/preview/features/ new-android-plugin-migration.html
https://developer.android.com/studio/build/dependencies.html#google-maven
添加Google的Maven存储库到buildscript存储库sect像@ KG87这样修复它确实这里。
Add Google’s Maven Repository to the buildscript repositories section to fix it like @KG87 did here.
buildscript {
repositories {
jcenter()
maven { url "https://maven.google.com" } // Add this line to fix it
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
...
}
}
正如所解释的这里:
buildScript块中的存储库用于获取buildScript依赖项的
依赖项。这些是放在构建的类路径上的
依赖项,你可以从构建文件中引用
。例如,互联网上存在
的额外插件。
The repositories in the buildScript block are used to fetch the dependencies of your buildScript dependencies. These are the dependencies that are put on the classpath of your build and that you can refer to from your build file. For instance, extra plugins that exist on the internet.
根级别的存储库用于获取项目所依赖的依赖项
上。所以
所需的所有依赖项都会编译你的项目。
The repositories on the root level are used to fetch the dependencies that your project depends on. So all the dependencies you need to compile your project.
和此处:
buildScript
block确定哪些插件,任务类和
其他类可用于其余构建脚本。
如果没有buildScript
块,您可以使用
Gradle开箱即用的所有内容。如果你还想使用第三方
插件,任务类或其他类(在构建脚本中!),你
必须在buildScript <中指定相应的依赖项/ code>
block。
The
buildScript
block determines which plugins, task classes, and other classes are available for use in the rest of the build script. Without abuildScript
block, you can use everything that ships with Gradle out-of-the-box. If you additionally want to use third-party plugins, task classes, or other classes (in the build script!), you have to specify the corresponding dependencies in thebuildScript
block.
正如宣布的这里:
Android Gradle Plugin 3.0.0-alpha3也通过
maven.google.com发布。
The Android Gradle Plugin 3.0.0-alpha3 was also released through maven.google.com.
所以,尝试通过添加Google的Maven资源库来修复它。
So, try to fix it by adding Google’s Maven Repository.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
此处还为其他依赖项添加存储库,例如这:
Also add the repository here for other dependencies like the support libraries like this:
确保存储库部分包含一个maven部分,其中
为 https://maven.google.com 端点。例如:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
区别在于这里
buildscript块仅控制buildscript
进程本身,而不是应用程序代码,顶级
依赖项块控制。
The "buildscript" block only controls dependencies for the buildscript process itself, not for the application code, which the top-level "dependencies" block controls.
例如,您可以定义buildscript / classpath中的依赖项
表示构建过程中使用的Gradle插件。那些插件
不会被引用为应用程序代码的依赖项。
For instance, you could define dependencies in "buildscript/classpath" that represent Gradle plugins used in the build process. Those plugins would not be referenced as dependencies for the application code.
评论在哪里,Bintray JCenter中不存在此版本:
As commented here by @lugegege, this version doesn't exist in Bintray JCenter:
com.android.tools.build.gradle
最新版本是2.5.0-alpha-preview-02,没有3.0.0-alpha3
com.android.tools.build.gradle latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3
这篇关于无法构建android项目它显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!