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 true,但我的项目无法正常工作。我不知道为什么。我的错是什么?

LogCat;

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

最佳答案

在API 21以下无法单独设置“ multiDexEnabled true”

您应该添加以下依赖项。

implementation 'com.android.support:multidex:1.0.3'


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

10-05 20:20