DexException:多个dex文件定义

时间:2016-10-23 16:27:03

标签: android android-studio gradle dex

我在Android Studio中遇到的错误如下:

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

Error:Execution failed for task ':app:transformClassesWithDexForInmemoryDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

包括的依赖性是:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile ('junit:junit:4.12')
compile ('com.android.support:appcompat-v7:23.2.1')
compile ('com.soundcloud.android:android-crop:0.9.10@aar')
compile ('com.squareup:otto:1.3.6')
compile ('com.squareup.picasso:picasso:2.5.2')
compile ('com.android.support:recyclerview-v7:+')
compile ('com.android.support:cardview-v7:+')
}

我尝试过将multidex设置为true,但它仍然没有解决问题。我也尝试在依赖项中排除support-v4。

请帮我解决错误。

1 个答案:

答案 0 :(得分:-2)

依赖于您的build.gradle“编译'com.android.support:multidex:1.0.1' 然后在attachBaseContext方法中打开您的应用程序类 写MultiDex.install(this); 希望它能帮到你