0

I'm trying to generate SignedAPK for deploying it in the Play Store, but I'm getting the following error. But while building as debug mode it works very fine.

ERROR:

Error:

Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/hardware/fingerprint/FingerprintManagerCompat$Api23FingerprintManagerCompatImpl$1.class

Build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.meru.parryreward"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}
configurations {

    all*.exclude group: 'com.android.support', module: 'support-annotations'
    all*.exclude group: 'com.android.support', module: 'support-v7'
    all*.exclude group: 'com.android.support', module: 'support-v4'


    //  all*.exclude group: 'com.android.support', module: 'support-vector-drawable'


  }
dexOptions {
    javaMaxHeapSize "4g"
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
testCompile 'junit:junit:4.12'
compile files('libs/android-support-v4.jar')

}

I have tried almost everything suggested in SO but couldn't resolve this error. I'm a beginner Thanks in advance.

EDIT:

 // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
   }
}

allprojects {
repositories {
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Rakesh Polo
  • 431
  • 1
  • 9
  • 27

2 Answers2

0

just delete android-support-v4.jar in your libs folder.. delete it

than Clean-Rebuild-Run your Project

if this android-support-v4.jar file is not added in the build.gradle file. gradle includes it in the build anyway.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
  • I removed that jar from my libs folder but now getting build errors on almost all the java files in the imports. @Nilesh – Rakesh Polo Oct 13 '17 at 04:40
  • try to complie this lib `compile 'com.android.support:design:26.0.0-alpha1'` – AskNilesh Oct 13 '17 at 04:41
  • i found the library in the external libraries. but when i right clicked on it. i couldn't able to find compile option. – Rakesh Polo Oct 13 '17 at 04:48
  • @RakeshPolo didn't get u – AskNilesh Oct 13 '17 at 04:49
  • As you told me earlier i am trying to compile the lib but dont know how to do it. – Rakesh Polo Oct 13 '17 at 04:51
  • add thet depedency in gardle than click build menu than click clear menu @RakeshPolo – AskNilesh Oct 13 '17 at 04:56
  • @RakeshPolo try this compile this lib `compile 'com.android.support:support-v4::26.0.+'` and `compile 'com.android.support:appcompat-v7:26.0.+` – AskNilesh Oct 13 '17 at 05:10
  • @RakeshPolo remove aplha version – AskNilesh Oct 13 '17 at 05:10
  • while adding the dependencies you told i am getting the following error. `Error:Could not find support-v4-26.0.+.jar (com.android.support:support-v4:26.0.0-alpha1). Searched in the following locations: file:/home/kumar/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/26.0.0-alpha1/support-v4-26.0.0-alpha1-26.0.+.jar Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager` – Rakesh Polo Oct 13 '17 at 05:32
0

This is probably because you have a conflicted support library version. You need to use the same support library version.

In your case, try using support-v4 library from maven instead of local jar:

dependencies {
  ...

  compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
  compile 'com.android.support:support-v4::26.0.0-alpha1'

  ...

}

Try using the recent support library which is 26.1.0. Never use alpha version in your release apk.

If your build.gradle only include all dependencies as your above answer, you don't need to enable multidex and set it as false with multiDexEnabled false. And also, try removing the following code in it:

configurations {

    all*.exclude group: 'com.android.support', module: 'support-annotations'
    all*.exclude group: 'com.android.support', module: 'support-v7'
    all*.exclude group: 'com.android.support', module: 'support-v4'


    //  all*.exclude group: 'com.android.support', module: 'support-vector-drawable'


  }
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • if i remove the configurations and add new dependencies im getting following error. `Error:Could not find support-v4-26.0.+.jar (com.android.support:support-v4:26.0.0-alpha1). Searched in the following locations: file:/home/kumar/Android/Sdk/extras/android/m2repository/com/android/support/support-v4/26.0.0-alpha1/support-v4-26.0.0-alpha1-26.0.+.jar Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager` – Rakesh Polo Oct 13 '17 at 05:34
  • You need to add the google maven. Please look at my answer about the maven: https://stackoverflow.com/questions/45357000/failed-to-resolve-com-android-supportappcompat-v726-0-0/45876864#45876864 – ישו אוהב אותך Oct 13 '17 at 05:35
  • I did that too `buildscript { repositories { jcenter() maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }` – Rakesh Polo Oct 13 '17 at 05:37
  • In the SDK tools i have installed everything that comes under support repository. still error persists. – Rakesh Polo Oct 13 '17 at 05:39
  • That's strange. Could you attach your **root** `build.gradle` in your question? – ישו אוהב אותך Oct 13 '17 at 05:52
  • I have added it. Please check – Rakesh Polo Oct 13 '17 at 06:06
  • add your maven to allProject: `allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } }` – ישו אוהב אותך Oct 13 '17 at 06:25