Gradle同步失败-将Android Studio更新为3.2后

时间:2018-10-04 08:15:50

标签: android android-studio android-gradle

绝对没有帮助,因为有人以前曾发现过类似的问题。 更新项目文件build.gradle:

buildscript {
    ext.kotlin_version = '1.2.71'

    repositories {
        mavenCentral()
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url 'https://maven.google.com' }
    }
}

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

还将依赖项和buildToolsVersion更新为'28.0.3'

但是Gradle同步仍然失败!

有人将Android Studio更新到3.2后解决了这个问题吗?

添加-我的应用程序build.gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    lintOptions {
        tasks.lint.enabled = false
    }
    flavorDimensions "local"
    signingConfigs {
        ...
    }
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "xxx"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 55
        versionName "2.0.7"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        signingConfig signingConfigs.release
        multiDexEnabled true
        renderscriptSupportModeEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/java'
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
    productFlavors {
        prod {
           ...
        }
        mytest {
            ...
        }
        local {
           ...
        }
    }
    useLibrary 'org.apache.http.legacy'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true
    }
    implementation 'com.android.support:appcompat-v7:28.0.3'
    implementation 'com.android.support:support-v4:28.0.3'
    implementation 'com.android.support:design:28.0.3'
    implementation 'com.android.support:customtabs:28.0.3'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.google.android.gms:play-services-places:11.8.0'
    implementation 'com.patloew.rxlocation:rxlocation:1.0.4'
    implementation 'com.google.maps.android:android-maps-utils:0.4.4'
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.karumi:dexter:2.3.1'
    implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'ru.egslava:MaskedEditText:1.0.5'
    implementation 'com.github.mukeshsolanki:country-picker-android:1.1.9'
    implementation 'io.michaelrocks:libphonenumber-android:8.4.1'
    implementation 'com.sothree.slidinguppanel:library:3.3.1'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    implementation 'com.afollestad:sectioned-recyclerview:0.4.1'
    implementation 'com.cocosw:bottomsheet:1.3.1@aar'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.andkulikov:transitionseverywhere:1.7.4'
    implementation 'com.facebook.shimmer:shimmer:0.1.0@aar'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
    implementation 'com.github.rey5137:material:1.2.5'
    implementation('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    implementation project(path: ':sdk')
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

repositories {
    mavenCentral()
    maven {
        url "http://repository.jetbrains.com/all"
    }
}

apply plugin: 'com.google.gms.google-services'

Android Studio还会记录是否有帮助:

2018-10-04 11:32:09,079 [ thread 19]   INFO - e.project.sync.GradleSyncState - Started setup of project 'xxx'. 
2018-10-04 11:32:09,083 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender activation event: SETUP_STARTED 
2018-10-04 11:32:09,242 [e-1136-b06]   INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 23 Platform' (/Users/nico/Library/Android/sdk) to module 'sdk' 
2018-10-04 11:32:09,263 [e-1136-b06]   INFO - ule.android.SdkModuleSetupStep - Set Android SDK 'Android API 28 Platform' (/Users/nico/Library/Android/sdk) to module 'app' 
2018-10-04 11:32:09,279 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/23.0.1/package.xml 
2018-10-04 11:32:09,282 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/24.0.2/package.xml 
2018-10-04 11:32:09,286 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/25.0.0/package.xml 
2018-10-04 11:32:09,289 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/25.0.2/package.xml 
2018-10-04 11:32:09,292 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/25.0.3/package.xml 
2018-10-04 11:32:09,296 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/26.0.1/package.xml 
2018-10-04 11:32:09,299 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/26.0.2/package.xml 
2018-10-04 11:32:09,303 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/26.0.3/package.xml 
2018-10-04 11:32:09,309 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/27.0.2/package.xml 
2018-10-04 11:32:09,313 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/27.0.3/package.xml 
2018-10-04 11:32:09,317 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/28.0.0-rc2/package.xml 
2018-10-04 11:32:09,321 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/28.0.2/package.xml 
2018-10-04 11:32:09,324 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/build-tools/28.0.3/package.xml 
2018-10-04 11:32:09,326 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/cmake/3.6.4111459/package.xml 
2018-10-04 11:32:09,330 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/docs/package.xml 
2018-10-04 11:32:09,333 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/emulator/package.xml 
2018-10-04 11:32:09,337 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/extras/android/gapid/3/package.xml 
2018-10-04 11:32:09,340 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/extras/android/m2repository/package.xml 
2018-10-04 11:32:09,344 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/extras/google/instantapps/package.xml 
2018-10-04 11:32:09,347 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/extras/google/m2repository/package.xml 
2018-10-04 11:32:09,350 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/package.xml 
2018-10-04 11:32:09,352 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/extras/m2repository/com/android/support/constraint/constraint-layout-solver/1.0.2/package.xml 
2018-10-04 11:32:09,354 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/extras/m2repository/com/android/support/constraint/constraint-layout/1.0.2/package.xml 
2018-10-04 11:32:09,358 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/ndk-bundle/package.xml 
2018-10-04 11:32:09,361 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/patcher/v4/package.xml 
2018-10-04 11:32:09,363 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platform-tools/package.xml 
2018-10-04 11:32:09,367 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-18/package.xml 
2018-10-04 11:32:09,370 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-21/package.xml 
2018-10-04 11:32:09,372 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-23/package.xml 
2018-10-04 11:32:09,375 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-24/package.xml 
2018-10-04 11:32:09,377 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-25/package.xml 
2018-10-04 11:32:09,380 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-26/package.xml 
2018-10-04 11:32:09,383 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-27/package.xml 
2018-10-04 11:32:09,385 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-28/package.xml 
2018-10-04 11:32:09,388 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/platforms/android-P/package.xml 
2018-10-04 11:32:09,390 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/sources/android-25/package.xml 
2018-10-04 11:32:09,422 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/sources/android-26/package.xml 
2018-10-04 11:32:09,425 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/sources/android-27/package.xml 
2018-10-04 11:32:09,428 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/sources/android-28/package.xml 
2018-10-04 11:32:09,432 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-19/google_apis/armeabi-v7a/package.xml 
2018-10-04 11:32:09,435 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-22/google_apis/x86/package.xml 
2018-10-04 11:32:09,439 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-23/google_apis/x86/package.xml 
2018-10-04 11:32:09,442 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-25/google_apis/arm64-v8a/package.xml 
2018-10-04 11:32:09,445 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-25/google_apis/armeabi-v7a/package.xml 
2018-10-04 11:32:09,450 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-26/google_apis/x86/package.xml 
2018-10-04 11:32:09,452 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-26/google_apis/x86_64/package.xml 
2018-10-04 11:32:09,455 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-26/google_apis_playstore/x86/package.xml 
2018-10-04 11:32:09,458 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-27/google_apis/x86/package.xml 
2018-10-04 11:32:09,460 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-27/google_apis_playstore/x86/package.xml 
2018-10-04 11:32:09,463 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-28/google_apis_playstore/x86/package.xml 
2018-10-04 11:32:09,466 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/system-images/android-28/google_apis_playstore/x86_64/package.xml 
2018-10-04 11:32:09,468 [ thread 18]   INFO - s.RepoProgressIndicatorAdapter - Parsing /Users/nico/Library/Android/sdk/tools/package.xml 
2018-10-04 11:32:09,585 [ thread 19]   INFO - e.project.sync.GradleSyncState - Gradle sync failed (10 s 350 ms) 
2018-10-04 11:32:09,598 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Consuming IndexingSuspender deactivation event: SYNC_FINISHED 
2018-10-04 11:32:09,598 [e-1136-b06]   INFO - idea.project.IndexingSuspender - Finishing batch update for project: Project '/Users/nico/android/navek/xxx' xxx
2018-10-04 11:32:09,610 [e-1136-b06]   INFO - pl.ProjectRootManagerComponent - project roots have changed 
2018-10-04 11:32:10,038 [ thread 21]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 2ms; general responsiveness: ok; EDT responsiveness: ok 
2018-10-04 11:32:10,068 [ thread 21]   INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 30ms; general responsiveness: ok; EDT responsiveness: ok 
2018-10-04 11:32:10,130 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Clearing symbols finished in 0,007 s. 
2018-10-04 11:32:10,133 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Building symbols in FAST mode, 0 source files from total 0 project files 
2018-10-04 11:32:10,133 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Loading symbols finished in 0,003 s. 
2018-10-04 11:32:10,133 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Loading Header Maps finished in 0,000 s. 
2018-10-04 11:32:10,133 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Loading Module Maps finished in 0,000 s. 
2018-10-04 11:32:10,134 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Saving Module Maps finished in 0,001 s. 
2018-10-04 11:32:10,134 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Loaded 0 tables for 0 files (0 project files) 
2018-10-04 11:32:10,134 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Building symbols for 0 source files 
2018-10-04 11:32:10,135 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Building symbols for 0 unused headers 
2018-10-04 11:32:10,135 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Building symbols finished in 0,001 s. 
2018-10-04 11:32:10,138 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Saving modified symbols for 0 files (0 tables of total 0) 
2018-10-04 11:32:10,138 [ thread 21]   INFO -       #com.jetbrains.cidr.lang - Saving symbols finished in 0,000 s. 

3 个答案:

答案 0 :(得分:0)

有时候,我只是复制了上一个有效的项目的gradle信息,并将其用于新项目,有时最新的buildToolVersion会失败,请尝试减少版本。 其他一些愚蠢的解决方案,但有时却起到了吸引人的作用:检查互联网,将android studio更改为离线工作模式,继续单击重试直到世界末日

答案 1 :(得分:0)

gradle同步失败的主要原因-在应用程序build.gradle中,阻止依赖项,需要将版本从28.0.3更改为28.0.0,并且gradle同步成功,但是面临以下问题Error during Sync: Broken pipe - after update Android Studio 3.2

答案 2 :(得分:0)

检查清单是否有问题。在我的情况下,它是{android:minSdkVersion},其他不应在[清单]中的字段应该在[build.gradle]中设置。