Failed to allow import of android.support.multidex.MultiDex after changing to the latest Multidex

I want to use multidex in my application, at first I used depedencies: 'com.google.android:multidex:0.1' , but after compilation this error appeared:

Error: execution completed for task ': packageAllDebugClassesForMultiDex'.

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

I changed 'com.google.android:multidex:0.1' on 'com.android.support:multidex:1.0.1' , but then import android.support.multidex.MultiDex; in the application class can not be resolved, can anyone help?

+6
source share
1 answer

Add this to 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 to 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> 
+4
source

All Articles