【问题标题】:Gradle sync failed after switching to 3.0 canary 5切换到 3.0 canary 5 后 Gradle 同步失败
【发布时间】:2017-07-04 07:16:13
【问题描述】:

切换到 Android Studio 3.0 canary 5 之后我无法构建我的 gradle 我发现错误是由于过时的 Guava 库引起的,但我没有在我的项目中使用 Guava .

项目 Gradle

buildscript {
ext.kotlin_version = '1.1.3'
repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
    classpath 'com.google.gms:google-services:3.1.0'
    classpath 'io.fabric.tools:gradle:1.22.2'
    classpath 'com.google.firebase:firebase-plugins:1.1.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

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

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

App Gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.firebase.firebase-perf'

android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
    applicationId "com.nrs.nsnik.notes"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 15
    versionName "1.9.5"
    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.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
    transitive = true;
}
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:26.0.0-beta2'
compile 'com.android.support:design:26.0.0-beta2'
compile 'com.android.support:cardview-v7:26.0.0-beta2'
compile 'com.android.support:palette-v7:26.0.0-beta2'
compile 'com.jakewharton:butterknife:8.6.0'
compile 'com.github.fafaldo:fab-toolbar:1.2.0'
compile 'com.google.firebase:firebase-perf:11.0.2'
compile 'com.google.firebase:firebase-ads:11.0.2'
compile 'com.google.android.gms:play-services-ads:11.0.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
compile 'com.android.support:customtabs:26.0.0-beta2'
compile 'com.google.guava:guava:22.0-android'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

错误:

Gradle sync failed: Cause: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
            Consult IDE log for more details (Help | Show Log) (18s 189ms)


Error:(1, 0) Unable to find method 'com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V'.

此意外错误的可能原因包括:

  • Gradle 的依赖缓存可能已损坏(这有时会在网络连接超时后发生。) 重新下载依赖并同步项目(需要网络)
  • Gradle 构建过程(守护程序)的状态可能已损坏。停止所有 Gradle 守护程序可能会解决此问题。 停止 Gradle 构建过程(需要重新启动)
  • 您的项目可能正在使用与项目中的其他插件或项目请求的 Gradle 版本不兼容的第三方插件。
在 Gradle 进程损坏的情况下,也可以尝试关闭 IDE,然后杀死所有 Java 进程。

【问题讨论】:

  • 您使用的是哪个版本的 gradle?检查你的 gradle-wrapper.properties
  • Gradle 4.1-milestone-1 build
  • 已解决,我必须删除类路径 'com.google.firebase:firebase-plugins:1.1.0' 并编译 'com.google.firebase:firebase-perf:11.0.2'
  • 当我尝试这个时,我得到一个Error:Could not find com.google.firebase:firebase-perf:11.0.2。有什么想法吗?

标签: android gradle android-gradle-plugin canary-deployment


【解决方案1】:

为我工作

    classpath ('com.google.firebase:firebase-plugins:1.1.0') {
        exclude group: 'com.google.guava', module: 'guava-jdk5'
    }

【讨论】:

  • 谢谢,至少构建已经成功完成。希望去掉番石榴不会有任何后果。
猜你喜欢
  • 2017-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多