迁移到New Places SDK客户端时,多个dex文件错误[关闭]


-1

我在我的应用中采用了Google Places sdk的新更新。我使用以下版本。但是我有问题。我不知道是什么原因造成的。我不知道错误中提到的F​​inalizableReferenceQueue是什么。

dependencies {
  implementation 'com.google.android.libraries.places:places:1.0.0'
}

建立项目时没有错误。该错误仅在我运行项目时显示。我正在使用Android Studio。

Multiple dex files define Lcom/google/common/base/FinalizableReferenceQueue;

您能否在gradle文件中发布其他依赖项的列表?
amuramoto

@amuramoto,您好,我终于找到了问题的原因。谢谢。以下是我的答案。
donmj

Answers:


1

经过反复试验,一次评论一个依赖项,我终于找到了问题。

apply plugin: 'com.android.application'

android {

compileSdkVersion 26
useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "xxx.com.xxx"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 201811141
    versionName "2018.11.14.1"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
 }
}

dependencies {
implementation 'com.google.android.libraries.places:places:1.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.maps.android:android-maps-utils:0.4+' 
implementation files('libs/acra-4.5.0.jar')
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation 'com.squareup.okhttp3:okhttp:3.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.android.support:cardview-v7:26.+'
implementation 'com.android.support:recyclerview-v7:26.+'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
// App's dependencies, including test
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'org.apache.httpcomponents:httpcore:4.4.1'
implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
implementation project(':aFileChooser')
}

//This are all the libraries that I commented to fixed the issue.
//implementation fileTree(include: ['*.jar'], dir: 'libs')//this will give mutidex error
//implementation files('libs/droid-fu-1.0-SNAPSHOT.jar')
//implementation files('libs/android-async-http-1.4.9.jar')
//compile 'com.squareup.retrofit2:converter-scalars:2.0.0'
//implementation 'cz.msebera.android:httpclient:4.3.6' //this will give error if use

0

万一其他人遇到这个问题,我将提供更多解释...

根本原因是该项目将DroidFu作为JAR进行了预编译,并将其作为依赖项进行了编译,该软件包打包了一些Guava类而没有重新标记包路径,从而导致Places SDK lib中的Guava依赖项版本冲突。

想要指出这一点,因为在依赖Guava的其他项目中这可能是一个问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.