无法构建android项目它显示错误

shi*_* kr 1 java android android-studio build.gradle android-gradle-plugin

项目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
}
Run Code Online (Sandbox Code Playgroud)

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'
Run Code Online (Sandbox Code Playgroud)

错误:配置根项目'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 https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0 -alpha3/gradle-3.0.0-alpha3.jar 要求:项目:

alb*_*elu 16

正如这里已经回答:

谷歌有新的maven回购,所以可能是原因.

https://android-developers.googleblog.com/2017/05/android-studio-3-0-canary1.html

部分谷歌的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存储库部分以修复它,就像@ KG87在这里所做的那样.

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'
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

正如解释在这里:

buildScript块中的存储库用于获取buildScript依赖项的依赖项.这些是放在构建的类路径上的依赖项,您可以从构建文件中引用它们.例如,互联网上存在的额外插件.

根级别上的存储库用于获取项目所依赖的依赖项.所以编译项目所需的所有依赖项.

在这里:

buildScript块确定哪些插件,任务类和其他类可用于构建脚本其余部分.如果没有buildScript块,您可以使用Gradle开箱即用的所有内容.如果您还想使用第三方插件,任务类或其他类(在构建脚本中!),则必须在buildScript 块中指定相应的依赖项.

正如在此宣布:

Android Gradle Plugin 3.0.0-alpha3也是通过maven.google.com发布的.

因此,请尝试通过添加Google的Maven资源库来解决此问题.

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
    }
}
Run Code Online (Sandbox Code Playgroud)

还要在此处添加存储库以获取其他依赖项,例如支持库,如下所示:

确保存储库部分包含带有" https://maven.google.com "端点的maven部分.例如:

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这里解释不同之处

"buildscript"块仅控制buildscript进程本身的依赖关系,而不是顶级"依赖关系"块控制的应用程序代码.

例如,您可以在"buildscript/classpath"中定义依赖项,这些依赖项表示构建过程中使用的Gradle插件.这些插件不会被引用为应用程序代码的依赖项.

正如@lugegege 在这里评论的那样,Bintray JCenter中不存在这个版本:

com.android.tools.build.gradle 最新版本是2.5.0-alpha-preview-02,没有3.0.0-alpha3


归档时间:

查看次数:

2898 次

最近记录:

8 年,8 月 前