繁体   English   中英

Gradle同步失败|| Android Studio

[英]Gradle sync failed || Android Studio

我收到错误消息Gradle同步失败。 我已经在stackoverflow上搜索了解决方案,发现了类似的问题,但是那里的解决方案无法解决我的问题:示例->

同步android gradle appcompat 27.0.1

构建Gradle // Project就是这样->:

buildscript {
    repositories {
        jcenter()
        maven { url "http://jcenter.bintray.com"}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'

    }
}
allprojects {
    repositories {
        mavenCentral()
        jcenter{ url "http://jcenter.bintray.com/" }
        maven {
            //url "https://jitpack.io"
            url "https://maven.google.com" // Google's Maven repository
        }

    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

生成gradle模块是这样的->:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "hibo.testxml"
        minSdkVersion 19
        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'
        }
    }
}
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.android.support:appcompat-v7:27.0.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'com.android.support:design:27.3.1'
    // FireBase
    compile 'com.firebase:firebase-client-android:2.3.1'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'com.google.firebase:firebase-core:11.8.0'

    testCompile 'junit:junit:4.12'

}//Add this line
apply plugin: 'com.google.gms.google-services'

我希望有人能帮助我解决这个问题。

ps:谢谢:D

顺便说一句,您的问题是您在构建工具和依赖项中使用了不同的版本。

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "hibo.test"
        minSdkVersion 19
        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'
        }
    }
}
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.android.support:appcompat-v7:27.0.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'com.android.support:design:25.3.1'
    // FireBase
    compile 'com.firebase:firebase-client-android:2.3.1'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'com.google.firebase:firebase-core:11.8.0'

    testCompile 'junit:junit:4.12'

}//Add this line
apply plugin: 'com.google.gms.google-services'

现在在您的gradle中使用它。 可能是您尚未安装27.0.3。 然后在gradle控制台中将出现错误。 然后通过单击错误安装这些工具。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM