我的代码正在构建并正常运行。但是在添加了图像选择器库Matisse
后,我遇到了以下错误。我试图在SO
和github
上找到很多类似的解决方案,但没有一个可以帮助我。即使我已将shrinkResources
和minifyEnabled
设为false,但错误也未被根除。
错误:
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define
Lit/sephiroth/android/library/imagezoom/ImageViewTouchBase$DisplayType;
Error: at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error: at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
错误:任务':app:transformDexArchiveWithDexMergerForDebug'执行失败。
com.android.build.api.transform.TransformException:com.android.dex.DexException:多个dex文件定义Lit / sephiroth / android / library / imagezoom / ImageViewTouchBase $ DisplayType; 错误:在java.util.concurrent.ForkJoinTask $ AdaptedCallable.exec(ForkJoinTask.java:1424) 错误:在com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36) 错误:在com.android.dx.merge.DexMerger.merge(DexMerger.java:198) 错误:在java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) 错误:在com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598) 错误:在java.util.concurrent.ForkJoinPool $ WorkQueue.runTask(ForkJoinPool.java:1056) 错误:在java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) 错误:在com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616) 错误:com.android.dex.DexException:多个dex文件定义Lit / sephiroth / android / library / imagezoom / ImageViewTouchBase $ DisplayType; 错误:在java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) 错误:在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Gradle Script:
apply plugin: 'com.android.application'
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "community.infinity"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
aaptOptions {
cruncherEnabled = false
}
dexOptions {
preDexLibraries false
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-
rules.pro'
}
debug {
ext.enableCrashlytics = false
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support'
exclude module: 'support-annotations'
exclude module: 'support-v4'
exclude module: 'support-v13'
exclude module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
})
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:design:27.0.0'
compile 'com.android.support:cardview-v7:27.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:support-v4:27.0.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.adamstyrc.cookiecutter:cookie-cutter:1.0.2'
compile 'com.allattentionhere:fabulousfilter:0.0.5'
compile 'com.github.florent37:diagonallayout:1.0.6'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.github.developer-shivam:FeaturedRecyclerView:1.0.0'
compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
compile 'gun0912.ted:tedbottompicker:1.0.12'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.github.pwittchen:swipe:0.1.0'
compile 'com.thesurix.gesturerecycler:gesture-recycler:1.4.0'
compile 'com.github.iammert:MaterialIntroView:1.6.0'
compile 'com.github.oxoooo:touch-image-view:1.0.1'
compile 'com.github.deano2390:MaterialShowcaseView:1.2.0'
//compile 'com.github.darsh2:MultipleImageSelect:v0.0.4'
compile 'com.github.darsh2:MultipleImageSelect:3474549'
compile 'com.github.lovetuzitong:MultiImageSelector:1.2'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
compile('io.socket:socket.io-client:0.8.3') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
compile 'com.google.gms:google-services:3.1.2'
compile 'com.github.mancj:MaterialSearchBar:0.7.5'
compile 'com.iceteck.silicompressorr:silicompressor:2.1'
compile 'com.fenchtose.nocropper:nocropper:0.2.0'
compile 'me.relex:circleindicator:1.2.2@aar'
compile('com.google.guava:guava:23.4-android') {
exclude group: 'com.android.support'
exclude module: 'support-annotations'
exclude module: 'support-v4'
exclude module: 'support-v13'
exclude module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile 'com.github.danylovolokh:hashtag-helper:1.1.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.orhanobut:hawk:2.0.1'
compile 'com.zsoltsafrany:needle:1.0.0'
compile 'com.github.madrapps:pikolo:1.1.6'
compile 'jp.wasabeef:richeditor-android:1.2.2'
compile 'com.android.support:palette-v7:27.0.0'
testCompile 'junit:junit:4.12'
compile('com.github.bumptech.glide:glide:4.4.0') {
transitive = true;
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
implementation 'com.android.support:multidex:1.0.2'
compile 'net.grandcentrix.tray:tray:0.12.0'
compile 'com.zhihu.android:matisse:0.4.3'
}