简体   繁体   English

Gradle同步失败|| Android Studio

[英]Gradle sync failed || Android Studio

I get the error message Gradle sync failed. 我收到错误消息Gradle同步失败。 I already searched for solutions on stackoverflow and found similar problems but the solution there could not solve my problem: Example--> 我已经在stackoverflow上搜索了解决方案,发现了类似的问题,但是那里的解决方案无法解决我的问题:示例->

syncing android gradle appcompat 27.0.1 同步android gradle appcompat 27.0.1

build Gradle//Project is like this-->: 构建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
}

and the build gradle module is like this-->: 生成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'

I hope somone can help me solve this problem. 我希望有人能帮助我解决这个问题。

ps:thanks in advance :D ps:谢谢:D

By The way your problem is that you are using different versions for build tools and in dependencies. 顺便说一句,您的问题是您在构建工具和依赖项中使用了不同的版本。

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'

Now use this in your gradle. 现在在您的gradle中使用它。 May be you have not 27.0.3 install. 可能是您尚未安装27.0.3。 Then an error will come in gradle Console. 然后在gradle控制台中将出现错误。 Then install these tools by clicking the error. 然后通过单击错误安装这些工具。

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

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