gpt4 book ai didi

java - Android Studio 多个 dex 文件定义

转载 作者:太空宇宙 更新时间:2023-11-04 10:40:36 27 4
gpt4 key购买 nike

我正在尝试构建 multidex 项目并收到一些错误:

:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources
:app:transformClassesWithRetrolambdaForDebug
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithDexMergerForDebug
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$OnPreDrawListener;","sources":[{}],"original":"UNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$OnPreDrawListener;\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$OnPreDrawListener;","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:198)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)","sources":[{}]}

FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$OnPreDrawListener;

我的build.gradle

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
}
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


repositories {
maven { url 'https://maven.fabric.io/public' }
}

android {
compileSdkVersion 27
buildToolsVersion '27.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1"
multiDexEnabled true

vectorDrawables.useSupportLibrary = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
signingConfig signingConfigs.release
shrinkResources false
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
shrinkResources false
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
}
}
}

repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
}
mavenCentral()
google()
}



dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
transitive = true
}

compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'


compile 'com.android.support:appcompat-v7:27.0.2'

compile 'com.android.support:design:27.0.2'

compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:27.0.2'


compile ('com.android.support:cardview-v7:27.0.2')

compile ('com.android.support:recyclerview-v7:27.0.2') {
exclude group: 'com.android.support.design.widget'
}

compile ('com.evernote:android-job:1.1.11')
compile ('com.google.android.gms:play-services-location:11.0.4')
compile ('com.google.android.gms:play-services-analytics:11.0.4')
compile ('com.google.firebase:firebase-messaging:11.0.4')
compile ('com.neovisionaries:nv-websocket-client:2.3')

compile ('com.squareup.okhttp3:okhttp:3.6.0')
compile ('com.squareup.okhttp3:okhttp-urlconnection:3.6.0')
compile ('com.squareup.okhttp3:logging-interceptor:3.6.0')
compile ('io.reactivex.rxjava2:rxandroid:2.0.1')
compile ('io.reactivex.rxjava2:rxjava:2.0.8')
compile ('com.artemzin.rxjava:proguard-rules:1.2.9.0')
compile ('com.squareup.retrofit2:converter-gson:2.2.0')
compile ('com.squareup.retrofit2:retrofit:2.2.0')
compile ('com.squareup.retrofit2:adapter-rxjava2:2.2.0')
compile ('io.requery:requery:1.4.0')
compile ('io.requery:requery-android:1.4.0')

compile 'com.android.support:multidex:1.0.1'
compile 'org.jsoup:jsoup:1.10.3'
testCompile 'junit:junit:4.12'
annotationProcessor 'io.requery:requery-processor:1.3.0'

compile 'org.xwalk:xwalk_core_library:19.49.514.5'

}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'me.tatarka.retrolambda'

我正在尝试使用

exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design-v13'
exclude group: 'com.android.support.design'
exclude group: 'android.support.design'

这没有帮助。如何从所有编译器中排除此库或以某种方式解决此问题的其他方法?

如何查看模块在哪些库中重复?

有趣的是 - 一小时前它有效,代码没有改变。构建正常,当我尝试在模拟器上安装应用程序时出现错误崩溃

最佳答案

我不知道怎么做,但它有帮助:

configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}

关于java - Android Studio 多个 dex 文件定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49027503/

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