无法解决此错误:Multidex已启用

时间:2016-10-24 07:33:28

标签: java android

Information:Gradle tasks [:app:assembleDebug] Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationExceptio
apply plugin: 'com.android.application'

android {     compileSdkVersion 23     buildToolsVersion" 21.1.2"

defaultConfig {
    applicationId "com.flikster.flikster"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
dexOptions {
    javaMaxHeapSize "2g"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.joooonho:selectableroundedimageview:1.0.1'
    compile 'com.makeramen:roundedimageview:2.2.1'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.google.android.gms:play-services:9.6.1'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.makeramen:roundedimageview:2.2.1'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    compile 'com.pnikosis:materialish-progress:1.5'


}

2 个答案:

答案 0 :(得分:1)

如果您没有任何扩展Application类的类

,请将以下行添加到AndroidManifest.xml中的应用程序标记中
android:name="android.support.multidex.MultiDexApplication"

如果您有任何扩展Application类的类

,请在onCreate()方法中添加以下内容
MultiDex.install(getBaseContext());

答案 1 :(得分:0)

创建应用程序类

在onCreate()

中初始化MultiDex
public class MyApplication extends Application {
private static MyApplication applicationContext;
public static boolean isNotificationProcessing = false;

public MyApplication() {
    applicationContext = this;
}

@Override
public void onCreate() {
    super.onCreate();

    MultiDex.install(getBaseContext());



}

}

重建并重新运行