更新Android Studio后出现以下错误。请帮我解决问题。
我在gradle中做错了或需要启用multidex?
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
这是我的gradle dependecies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.github.citux:datetimepicker:0.2.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
compile 'com.google.zxing:core:3.0.1'
compile 'com.embarkmobile:zxing-android-legacy:2.0.0@aar'
compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.6@aar') {
transitive = true;
}
先谢谢。
答案 0 :(得分:1)
这是因为2个问题
首先:您可能没有指定以下
`multiDexEnabled true`
public class YouApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
否则你可能会使用像
YouApplication extends MultiDexApplication
和
attachBaseContext
你可以做其中任何一个。你不能一起使用
答案 1 :(得分:0)
我通过更改依赖项来修复此问题
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.github.citux:datetimepicker:0.2.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
compile 'com.google.zxing:core:3.0.1'
compile 'com.embarkmobile:zxing-android-legacy:2.0.0@aar'
compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.6@aar') {
transitive = true;
}
做了两处修改
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'