Error:Execution failed for task ':app:dexDebug' error in my project while I added new dependency

淺唱寂寞╮ 提交于 2019-11-27 09:48:02

you can use below code also with IntelliJ Amiya answer. In some case this code work for me

 dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}

android {
compileSdkVersion 23
 buildToolsVersion "23.0.1"

     defaultConfig {
         minSdkVersion 14 //lower than 14 doesn't support multidex
         targetSdkVersion 22

         // Enabling multidex support.
         multiDexEnabled true
     }
}

you can do by make an Application class

public class MyApplication extends MultiDexApplication { .. }

or

override 
 attachBaseContext method and call MultiDex.install().
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}

Otherwise (if your application does not have custom Application implementation), declare MultiDexApplication as application implementation in your AndroidManifest.xml.

<application
android:name="android.support.multidex.MultiDexApplication"
.. >
..
</application>
IntelliJ Amiya

At first you can use compile 'com.squareup.okhttp:okhttp:2.5.0' instead of yours . You can read my answer DexIndexOverflowException

android {
    compileSdkVersion 23
buildToolsVersion "23.0.1"

         defaultConfig {
             minSdkVersion 14 //lower than 14 doesn't support multidex
             targetSdkVersion 22

             // Enabling multidex support.
             multiDexEnabled true
         }
}

dependencies {
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
}

http://developer.android.com/intl/es/tools/building/multidex.html

add

useLibrary  'org.apache.http.legacy'

in your gradle before the compileSdkversion...

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