【问题标题】:Android: Multiple dex files define Lcom/google/android/gms/location/places/zza;Android:多个dex文件定义Lcom/google/android/gms/location/places/zza;
【发布时间】:2020-01-19 03:51:36
【问题描述】:

我无法停止每次都收到此错误,我不知道是什么原因造成的以及如何解决它:

Multiple dex files define Lcom/google/android/gms/location/places/zza;

我认为这可能与google-services 有关,但我并不完全确定。

app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.xxxx.xxxx"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 10173
        versionName "4.3"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    // Fixes "Duplicate files copied in APK" build bug
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    // Pushy SDK
    implementation 'com.google.firebase:firebase-messaging:17.5.0'

    compile 'me.pushy:sdk:1.0.43'

    // AppCompat v7 Dependency
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.google.android.gms:play-services-maps:16.1.0'
    compile 'com.google.android.gms:play-services-places:10.2.0'
    // Google Play Services Dependencies
    compile 'com.google.android.gms:play-services-location:16.0.0'

    compile 'com.google.android.gms:play-services-ads:17.1.1'

    // All .jar files in ./libs
    compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 见这里:stackoverflow.com/questions/36912079/…。问题是您的依赖项中有所有 google play 服务,这行:compile 'com.google.android.gms:play-services:10.2.0'。只需使用您的应用所需的各个库。
  • 我更新了问题中的代码,现在又收到一个错误:“Multiple dex files define Lcom/google/android/gms/location/places/zza;”
  • 您使用的是旧版本的 places,该版本已被弃用。将地点更新到新地点库:developers.google.com/places/android-sdk/client-migration

标签: android android-studio build.gradle


【解决方案1】:

如果您的应用有超过 65535 个方法,您需要为您的应用启用 multidex 格式。

这可能是由于您的项目中有大量依赖项造成的。

【讨论】:

  • 多个dex文件定义Lcom/google/android/gms/location/places/zza;收到此错误
  • @redalert 我目前不确定。但必须有解决办法。谷歌可能会有所帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-07-01
  • 2018-01-15
  • 2017-08-14
  • 1970-01-01
  • 2018-10-15
  • 1970-01-01
相关资源
最近更新 更多