gpt4 book ai didi

java - 构建错误(将字节码转换为 dex 时出错)

转载 作者:搜寻专家 更新时间:2023-11-01 09:27:55 27 4
gpt4 key购买 nike

当我尝试构建 android 项目时,出现如下错误。

Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Landroid/arch/lifecycle/LiveData$LifecycleBoundObserver;

我多次搜索stackoverflow来解决这个问题,但我仍然有这个错误。

我认为这是因为一些库版本冲突造成的。但是我没有找到问题所在。

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "my.app.idhere"
minSdkVersion 19
targetSdkVersion 27
versionCode 4
versionName "1.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = ['appIdRedirectScheme': android.defaultConfig.applicationId]
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

/* This for anyone following along with the repo. Since you will have a different
* root URL, this code loads up a value from your gradle.properties file.
*/
buildTypes.each {
it.buildConfigField 'String', 'GOOGLE_API_BASE_URL', GoogleApiBaseUrl
it.buildConfigField 'String', 'IBM_API_BASE_URL', IBMApiBaseUrl
}

packagingOptions {

exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}

// dexOptions {
// preDexLibraries = false
// }

}

repositories {
mavenCentral()
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:27.1.0'
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.android.support:design:27.1.0'

// compile group: 'com.cloudant', name: 'cloudant-sync-datastore-android', version:'1.1.5'

// Google Play Services
implementation 'com.google.android.gms:play-services-maps:12.0.0'
implementation 'com.google.android.gms:play-services-location:12.0.0'
implementation 'com.google.android.gms:play-services-places:12.0.0'

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

implementation 'com.ibm.mobilefirstplatform.clientsdk.android:analytics:1.2.+'
implementation 'com.ibm.mobilefirstplatform.clientsdk.android:push:3.7.0'
implementation 'com.github.ibm-cloud-security:appid-clientsdk-android:3.+'


implementation 'com.google.maps.android:android-maps-utils:0.5+'
implementation 'com.google.firebase:firebase-messaging:12.0.0'

// Glide
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'

implementation 'com.android.volley:volley:1.0.0'

implementation 'com.android.support:cardview-v7:27.1.0'

// compile 'commons-io:commons-io:2.4'

// Mapbox

implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0@aar') {
transitive = true
}
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.11.1'
implementation('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.11.1') {
transitive = true
}

implementation 'com.android.support:multidex:1.0.1'

}

// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'

Note: when I remove the mapbox from gradle, then error is disappeared but I need to use mapbox.

最佳答案

最后我通过添加这个 gradle 解决了这个问题。

implementation "android.arch.lifecycle:extensions:1.1.1"

添加 multidex 并清理和重建项目后,再次出现生命周期错误。

通过添加上面的 gradle 解决了这个问题。

关于java - 构建错误(将字节码转换为 dex 时出错),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49458601/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com