android pre dex errors in Android Studio

一个人想着一个人 提交于 2019-12-12 03:06:53

问题


I recently try to open up a project developed sometime ago into Android Studio and try to rebuild it and I get whole load Android Pre Dex errors which I am totally stuck how I get rid of them. Tried a lot of stuff such as changing Android API level, cleaning, change jdk version.. all doesn't work.

Any experts out there can enlighten me what is the likely cause of these errors.?

android pre dex errors screenshot


回答1:


Step 1: Add multidex enabled in default config

defaultConfig {
    applicationId "Your package name"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 5
    versionName '1.0.5'
    multiDexEnabled true
}

Step 2 : Add this library in your dependencies

    compile 'com.android.support:multidex:1.0.0'

Step 3 : Add this line in your MyApplication extends Application java class

 MultiDex.install(this);

Step 4: Don't forgot to call MyApplication class in your Application tag of manifest file. Like this

 android:name=".MyApplication"

After this 4 steps clean your project and run the application. Surely it will helps you!

Happy Coding!




回答2:


i already solved it it happen because you didnt setting the default java in android studio 2.3.3 or android studio 3.0 beta 6

  1. go to file > project structure > SDK location
  2. change the JDK Location to C:\Program Files\Java\jdk1.8.0_131



来源:https://stackoverflow.com/questions/38635783/android-pre-dex-errors-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!