0

I am getting the following error after updating Android Studio. Please help me with solution.

I am doing any mistake in the gradle or need to enable multidex?

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

Here is my 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;
}

Thanks in Advance.

tinto mathew
  • 216
  • 4
  • 22
  • It's a multidex exception .Enable multidex true .Refer this http://stackoverflow.com/a/38887728/3111083 – Sunil Sunny Aug 30 '16 at 06:39
  • @sunilsunny How did you get to conclusion that multi-dex is required here? – Alex Lipov Aug 30 '16 at 14:45
  • It looks like one of your dependencies brings support-v4 library in addition to the one that you explicitly declare. See my [answer here](http://stackoverflow.com/a/32049088/1233652) for a similar issue. – Alex Lipov Aug 30 '16 at 14:46

2 Answers2

1

this is because of 2 problems

first:you might not have specified the following

         `multiDexEnabled true`

'

public class YouApplication extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

}

otherwise you might have used like

YouApplication extends MultiDexApplication

and

attachBaseContext

u can do either one of them. u cant use both together

jafarbtech
  • 6,842
  • 1
  • 36
  • 55
  • How did you get to conclusion that multi-dex is required here? – Alex Lipov Aug 30 '16 at 14:44
  • com.android.dex.DexException: Multiple dex files define this error significantly specifies multidex error as multidex is not enabled... So go on with multidex – jafarbtech Aug 30 '16 at 17:11
  • No, it's not. Not every exception that contains 'dex' in its name requires to use multi-dex. It just says that during the dex merge process, same class appears in two modules (dexes). – Alex Lipov Aug 30 '16 at 20:04
  • You are ryt @Alex.I just changed the dependencies like this and it's fine now.No need of enabling Multidex... – tinto mathew Aug 31 '16 at 10:23
0

I fix the issue by changing the dependencies

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;
}

Made two changes

 compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
tinto mathew
  • 216
  • 4
  • 22