1
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'
}

This is my grandle. I added multiDexEnabled true on defaultConfing but my project doesn't work. I dont know why. What is the my mistake ?

LogCat ;

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Zibian Domichi
  • 185
  • 1
  • 11
  • remove this lines `compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }` – Abhay Koradiya Jun 02 '18 at 11:38
  • when i delete this row i get this errors Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\muham\.gradle\caches\modules-2\files-2.1\org.brunocvcunha.instagram4j\instagram4j\1.7\5d78b62994661553adf8da845bfc4c053bdd0b96\instagram4j-1.7.jar Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26) – Zibian Domichi Jun 02 '18 at 11:41
  • When I tried Your gradle , I have no problem at all. – Abhay Koradiya Jun 02 '18 at 11:53
  • Can you run the app ? – Zibian Domichi Jun 02 '18 at 11:56

1 Answers1

2

Setting 'multiDexEnabled true' alone will not work below API 21

You should add the following dependency.

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

Alternatively you could set your minSdkVersion to 21

xianskel
  • 61
  • 3