程序类型已经存在:com.google.android.gms.internal.zzak

时间:2018-07-28 04:48:43

标签: android

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.android.gms:play-services-maps:11.6.0'//error: mixing versions
implementation 'com.android.support:multidex:+'
implementation 'com.google.android.gms:play-services:9.4.0'
}

这是我对Android应用程序的依赖。 我使用的是Google地图,突然无法编译,出现此错误。

Program type already present: com.google.android.gms.internal.zzak
Message{kind=ERROR, text=Program type already present:    com.google.android.gms.internal.zzak, sources=[Unknown source file], tool     name=Optional.of(D8)}

我认为这与我的gradle.build有关 我真的不明白什么是“不要混用版本”的含义。我应该如何知道应该使用哪个版本?

2 个答案:

答案 0 :(得分:2)

implementation 'com.google.android.gms:play-services-maps:11.6.0'implementation 'com.google.android.gms:play-services:9.4.0'库的一部分,在build.gradle文件中,这两个库都应使用相同的版本

答案 1 :(得分:1)

  • 父母项目
  • 中添加Google Play服务classpath

build.gradle

dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.2.1' // google-services plugin
    }
}

allprojects {
    repositories {
        jcenter()
        google() // Add Google repo 
    }
}
    应用程序模块依赖项的底部
  • 应用Google play services插件。

build.gradle

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.android.gms:play-services-maps:15.0.1'//error: mixing versions Because it's already included on last dependency Please ready this below comments.

    implementation 'com.android.support:multidex:1.0.3' // You may not need this line after using ONLY what you need from Google play services.

//    Avoid using bundled version of Google Play services SDK. less... (⌘F1)
//    Google Play services SDK's can be selectively included, which enables a smaller APK size. Consider declaring dependencies on individual Google Play services SDK's. If you are using Firebase API's (http://firebase.google.com/docs/android/setup), Android Studio's Tools → Firebase assistant window can automatically add just the dependencies needed for each feature.  More info: http://developers.google.com/android/guides/setup#split
    // implementation 'com.google.android.gms:play-services:12.0.1'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'