Android gradle google-services 构建失败 "Duplicate Entry"

标签 android gradle android-gradle-plugin build.gradle gradlew

编辑:

我改变了这一行:

compile 'com.google.android.gms:play-services-analytics:8.1.0'

收件人:

compile 'com.google.android.gms:play-services-analytics:8.4.0'

我将类路径更改为:

classpath 'com.google.gms:google-services:2.0.0-alpha7'

并将 gradle 版本更新到 2.10 以修复我提到的另一个问题。现在我每次构建时都会遇到此错误:

Error:Execution failed for task ':app:processDebugGoogleServices'.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0.

-------------------------------------------- ---------------------------------------------- ----------------------------

原始问题

无中生有,我的应用无法成功构建。我尝试更新 google-services,但仍然收到错误消息。

What went wrong: Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/identifier/AdvertisingIdClient$Info.class

我的 gradle 也出现错误,在以下行:

    compile 'com.google.android.gms:play-services-analytics:8.1.0'

说一些谷歌库是 8.4.0 版,一些是 8.1.0 版。我尝试将谷歌图书馆升级到 8.4.0。 gradle 不会构建并给我以下错误:

Warning:Gradle version 2.10 is required. Current version is 2.8. If 
 using the gradle wrapper, try editing the distributionUrl in 
/Users/essam/Desktop/Apptuto/gradle/wrapper/gradle-wrapper.properties 
to gradle-2.10-all.zip

这是我的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:1.3.0'
    classpath 'com.google.gms:google-services:1.4.0-beta3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
}
}

应用程序等级:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: "findbugs"
apply plugin: "pmd"
android {
android {
    useLibrary 'org.apache.http.legacy'
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
    applicationId "my package name is written here"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.1"
    multiDexEnabled true
}

buildTypes {

    release {
        minifyEnabled false
        shrinkResources false
    }
    debug {
        debuggable true
    }
}


}
findbugs {
ignoreFailures = true
toolVersion = "2.0.1"
reportsDir = file("$project.buildDir/reports/findbugs")
effort = "max"
}

pmd {
ignoreFailures = true
reportsDir = file("$project.buildDir/reports/pmd")
ruleSets = [
        "basic",
        "braces"
]
}


dependencies {
compile('com.mikepenz:materialdrawer:4.3.7@aar') {
    transitive = true

}
repositories {
    mavenCentral()
    maven {
        url 'https://dl.bintray.com/intercom/intercom-maven'
    }
}

compile('io.intercom.android:intercom-sdk:1.+@aar') {
    transitive = true
}
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.1.1'

最佳答案

规则是所有 google play 服务都应该使用相同的版本 虽然我只能看到使用 8.1.0 的一行,但您可能有另一个使用 8.4.0 的库,只需将您的库编辑为 8.4.0 而不是 8.1.0

现在对于另一个错误,我不知道,它没有发生在我身上我复制了你的确切 gradle 并编译了

如果它一直出现,请尝试删除您的第二行:

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

你为什么要用这个?

关于Android gradle google-services 构建失败 "Duplicate Entry",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34982152/

相关文章:

java - SonarQube:获取错误报告在分析过程中找不到找不到路径或找不到目录和类

android - Android Studio中依赖GitHub仓库

kotlin - 如何在 buildSrc 模块中导入 KotlinMultiplatformExtension?

android - 当 ionic cordova 在 Mac 10.x 上构建 android 时,gradle 失败

android - 如何根据 android 构建变体包含不同的 .aar

android - 是否可以在没有 APNS 的情况下发送推送通知(使用 signalR)?

java - 在 android 中使用模型类时,Firestore FieldValue.ServerTimestamp 始终为空?

android - 无法使用 react-native 为 android 构建

android - Genymotion 虚拟机将 Theme.Holo.DialogWhenLarge 主题 Activity 显示为正常 Activity

android - 添加监听器以在操作栏中切换