Android multiDexEnabled错误

时间:2018-06-02 10:51:20

标签: android android-gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.example.mhmdalmz.unfollowsky"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        multiDexEnabled true
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    useLibrary 'org.apache.http.legacy'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    compile 'org.brunocvcunha.instagram4j:instagram4j:1.7'
}

这是我的爷爷。我在defaultConfing上添加了multiDexEnabled,但是我的项目不起作用。我不知道为什么。我的错是什么?

LogCat;

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

1 个答案:

答案 0 :(得分:2)

设置' multiDexEnabled true'单独不能在API 21下工作

您应该添加以下依赖项。

final ObjectMapper mapper = new ObjectMapper();

Claims jwsMap = Jwts.parser()
       .setSigningKey("SECRET")
       .parseClaimsJws("jwt")
       .getBody();
return mapper.convertValue(jwsMap, MyCustomClaim.class);

或者,您可以将minSdkVersion设置为21