0

when generate signed apk, has this error, but build project is ok

Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;

gradle:

apply plugin: 'com.android.application'

repositories {
    maven {
        url 'https://raw.github.com/71241NW123CK/maven-repo/master'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.baclock"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 18
        versionName "2018.02.09"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        incremental false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'party.treesquaredcode.android:flip-animation:0.0.2'
    compile 'com.mcxiaoke.volley:library:1.0.6'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.evernote:android-job:1.2.4'
}

apply plugin: 'com.google.gms.google-services'
Banana
  • 2,435
  • 7
  • 34
  • 60
Jack
  • 11
  • 3

2 Answers2

0

Add multiDexEnabled true in default config and then try.

defaultConfig {
        applicationId "com.baclock"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 18
        versionName "2018.02.09"
        multiDexEnabled true
    }
Umar Hussain
  • 3,461
  • 1
  • 16
  • 38
  • Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/text/ICUCompatIcs.class – Jack Feb 23 '18 at 01:23
  • 1
    thanks, need to set multiDexEnabled = true and minSdkVersion > 20 – Jack Feb 23 '18 at 01:29
  • so you don't want to increase the minimum sdk version or is it working for you now?. – Umar Hussain Feb 23 '18 at 07:07
  • yes, now is ok, thanks – Jack Feb 24 '18 at 00:38
0

Add multiDexEnabled = true inside defaultConfig block.

defaultConfig {
        applicationId "com.baclock"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 18
        versionName "2018.02.09"
        multiDexEnabled true
    }
Ankita
  • 1,129
  • 1
  • 8
  • 15
  • Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/text/ICUCompatIcs.class – Jack Feb 23 '18 at 01:23
  • thanks, need to set multiDexEnabled = true and minSdkVersion > 20 – Jack Feb 23 '18 at 01:29