Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Resolve import android.support.multidex.MultiDex after change to newest Multidex

I want to use multidex in my application, At First I used depedencies : 'com.google.android:multidex:0.1', but after compile this error appeared :

Error:Execution failed for task ':packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: android/support/multidex/BuildConfig.class

then I changed 'com.google.android:multidex:0.1' to 'com.android.support:multidex:1.0.1', but after that import android.support.multidex.MultiDex; in application class cannot be resolved, anybody can help ?

like image 239
Redturbo Avatar asked Dec 15 '15 10:12

Redturbo


1 Answers

Add this into your build.gradile

 android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
}
...
}

dependencies {
compile 'com.android.support:multidex:1.0.0'
}

Also add this into your manifest

   <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.example.android.multidex.myapplication">
       <application
           ...
           android:name="android.support.multidex.MultiDexApplication">
           ...
       </application>
    </manifest>
like image 194
Lijo Mathew Avatar answered Oct 05 '22 21:10

Lijo Mathew