I got this error when I tried to run my Android program.
Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'.
java.lang.AssertionError: java.util.zip.ZipException: duplicate entry: jayce/org/hamcrest/BaseDescription.jayce
here is my build.gradle
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.surgical.decision"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile files('libs/simple-xml-2.7.1.jar')
compile files('libs/log4j-1.2.17.jar')
compile files('libs/pddl4j-3.5.0.jar')
}
I have to enable jackOptions because there are a lot of function that I wrote in Java 8.
I had that same problem. I believe that com.android.support.test.espresso:espresso-core:2.2.2 is compiled with hamcrest and I think that com.android.support:appcompat-v7:25.3.1 also is compiled with hamcrest. I believe the error message is telling you that the hamcrest package is contained in at least two of the compiled jar and it can't resolve the duplicate issue (even though they are the same version). It probably can't resolve the duplicate due to some Jack technicality. To get around the problem, you just need to exclude it from one or the other:
i.e
`androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'org.hamcrest', module: 'hamcrest-core'
})
or if you're not really using espresso-core, just delete the androidTestCompile line altogether.
In my situation, I also had to add:
exclude group: 'junit', module: 'junit'
because I was getting a slightly different error due to the inclusion of two different junit versions conflict.
The best technique for debugging these kinds of errors is by using gradle from a command line.
open command prompt
navigate to project directory (it contains gradlew.bat)
gradlew app:androidDependencies
Related
I need the org.springframework.data.geo.Point class in my Spring Android app. I have the spring-android dependency already downloaded here. This does not have the .data section. When I try to use Gradle to import a different library I get duplication file errors. After consulting this link I get errors involving Dex cannot parse version 52 byte code. While reviewing this previous post I read that this wasn't the recommend way of getting rid of these errors.
Is there a spring library that I can import that has the org.springframework.data as well as everything given in the org.springframework.android:spring-android-rest-template:2.0.0.M3 library.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.avi.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
//pickFirst 'META-INF/spring.schemas'
//pickFirst 'META-INF/spring.tooling'
//pickFirst 'META-INF/spring.handlers'
//pickFirst 'META-INF/spring.factories'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
Error Message after following this:
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/spring.schemas
File1: C:\Users\Avi.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.0.2.RELEASE\1befa3239976b856202b1735531910a0c2f4e17f\spring-data-commons-2.0.2.RELEASE.jar
File2: C:\Users\Avi.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.0.2.RELEASE\301ee07b390bc8b5691f4206411b49beb06f7ff2\spring-beans-5.0.2.RELEASE.jar
Error Message after following this:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
I get an error when I try to use iText to generate a PDF at run time.
The error comes when the Application is run in device or geny Motion.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/lowagie/bc/asn1/ASN1Encodable.class.
My Gradle Code is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.visioneering.tfd"
minSdkVersion 15
targetSdkVersion 24
versionCode 5
versionName "1.5"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
android {
lintOptions {
checkReleaseBuilds false
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.github.florent37:materialtextfield:1.0.5'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.itextpdf:itext7-core:7.0.3'
compile 'com.itextpdf:itext-pdfa:5.5.11'
compile 'itext:itext:1.3.1'
compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Please help me to solve this problem.
duplicate entry: com/lowagie/bc/asn1/ASN1Encodable.class - that points to iText 2.1.7 or older, which is not known to be compatible with Android.
There are a couple of things wrong in your Gradle file:
compile 'com.itextpdf:itext-pdfa:5.5.11' - that points to the PDF/A add-on of iText 5, version 5.5.11, which is compatible with Android, but you still need the Android port of iText 5, which is called iTextG. So you need to add compile 'com.itextpdf:itextg:5.5.10'. Yes, 5.5.10, not 5.5.11, because there is no itextg:5.5.11. See http://repo1.maven.org/maven2/com/itextpdf/itextg/
I am guessing that you think the "a" in "pdfa" means Android, but it doesn't. It stands for PDF/A: the PDF spec for archiving (ISO 19005), see https://en.wikipedia.org/wiki/PDF/A. If you don't need archiving (you probably don't, in a typical Android app), so you probably need to remove compile 'com.itextpdf:itext-pdfa:5.5.11'
compile 'com.itextpdf:itext7-core:7.0.3' - this is iText 7, which is not compatible with Android. Remove that line.
compile 'itext:itext:1.3.1' - is an ANCIENT version of iText, and is probably what is causing your error. Remove that line.
compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6' - this is something special, which I don't know enough about. It may or may not pull in another dependency of iText, which may or may not be the wrong version. Tag your question with flying-saucer to attract extra attention.
When I build android app it can take from 5 minutes to 15 minutes.
How to solve problem whith memory. Is there a way to reduce memory consumption?
How make build faster?
my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.philliphsu:bottomsheetpickers:2.3.3') {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'gridlayout-v7'
}
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.philliphsu:bottomsheetpickers:2.3.3'
compile 'com.vk:androidsdk:1.6.8'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}
also my gradle.properties
org.gradle.jvmargs=-Xmx1536m
org.gradle.daemon=true
org.gradle.parallel=true
also add report
Why it takes so long and how you can speed up the assembly of the project?
Everyone will give different different opinions, but I recently fixed it by disabling my Antivirus Software. Disable the firewall, because it interrupts the Gradle Daemon from starting so OpenJDK Platform binary will be keep executing again n again, ultimately the memory out of crash will happen for the system.
UPDATE: Make sure, Wireless Hotspot is Turned Off. That's most important, while building the Project, the Hotspot must not be On.
Do this, and Thanks me later 💖
Starting Gradle Daemon...
Gradle Daemon started in 4 s 291 ms
Starting Gradle Daemon...
Gradle Daemon started in 5 s 664 ms
Starting Gradle Daemon...
Gradle Daemon started in 2 s 210 ms
Starting Gradle Daemon...
Gradle Daemon started in 7 s 258 ms
Solution - not using Jack. Read here https://developer.android.com/studio/preview/features/java8-support.html
Thanks #BladeCoder
Couple of days ago, I upgraded my Android Studio, and now I am facing a problem.
Actually I am trying to build an APK file from my project to test my app on a real device and when I click at Build--> Build Apk then I receive couple of errors in Message Gradle Build. I don't know why these errors are coming please elaborate on the reason as well.
Errors
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/android/volley/VolleyError;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 2
build.gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dovezeal.gapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// Volley
compile 'com.android.volley:volley:1.0.0'
//compile 'com.mcxiaoke.volley:library:1.0.+'
/* compile files('libs/com.mcxiaoke.volley library-1.0.0.jar')*/
// RecyclerView
compile 'com.android.support:recyclerview-v7:23.0.+'
// A simple way to define and render UI specs on top of your Android UI.
compile 'org.lucasr.dspec:dspec:0.1.1'
compile files('libs/library-1.0.0.jar')
// YouTube Player
compile files('libs/YouTubeAndroidPlayerApi.jar')
// GOSN
/* compile files('libs/gson-2.2.3.jar')*/
}
Edit - 1
As janki gadhiya said in her comment below, to change minifyEnabled true and try adding multiDexEnabled true under defaultConfig
with these changes both errors above are gone, but now this following error is coming up.
Error:Execution failed for task:app:transformClassesWithJarMergingForDebug'
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/android/volley/Request$Priority.class
build.gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dovezeal.gapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// as you already compiled gradle for volley here
compile 'com.android.volley:volley:1.0.0'
// RecyclerView
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'org.lucasr.dspec:dspec:0.1.1'
// you don't need this so comment the below line.
//compile files('libs/library-1.0.0.jar')
// YouTube Player
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
Edit : Explanations
Your errors 1 - 2 : mean you are having more than 65,000 methods in your project, so I told you to set multiDexEnable true.
Your error 3 : means you're having more than one library having the implementation for the class Request$Priority.class, so the compiler is confused which to choose. So it is showing the error Duplicate entry. This will be solved by packaging options, this will let you use duplicate files.
Add this in your build gradle
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
I am also getting the same error. When adding the
compile 'com.google.firebase:firebase-ads:10.2.0'
but it is removed when i do as follow:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.firebase:firebase-ads:10.2.0'
}
apply plugin: 'com.google.gms.google-services'**
and in BuildVarient use debugging mode.
I think it will help you.
while updating firebase any google play services then try to update all the libraries. this worked for me. hope it works in some cases.
Bit late to answer but I faced the same issue.
I was able to rectify it using multiDexEnabled -> true
and used packaging options in build.gradle, post the changes .apk got installed successfully.
Syntax:
defaultConfig {
....
....
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
...
...
}
Hope it helps.
I've been working on this issues for a several hours but can't find the solution. Tried a lots of answers from stackoverflow but no luck.
What am I getting is the following gradle error while running the app:
:app:packageAllDebugClassesForMultiDex FAILED
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/widget/SearchViewCompatIcs$MySearchView.class
Android studio throws the error when i add the dependency of ShareThis Sdk into the gradle. Here is the full gradle:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'Alies'
keyPassword 'password'
storeFile file('path.jks')
storePassword 'password'
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "example.com.app"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
incremental true
}
//configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
//configurations { all*.exclude module: 'support-v4' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided files('libs/universal-image-loader-1.9.3.jar')
compile project(':library-circular')
compile('com.android.support:appcompat-v7:22.2.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':sliding_library1')
compile('com.google.android.gms:play-services:7.5.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':sdk')
}
A small help will be greatly appreciated.
Seems the problem is in Compile independent modules in parallel (may require larger heap size). So, disabling that option and clear rebuild should fix it.
Looks like Android Build Tools for multidex sometimes try to include lib project in both dex files and it causes some conflict then compiled simultaneously.
So, the problem has been resolved. Actually there was a conflict between support-v4 jar files, So I simply used the same support-v4.jar everywhere and the problem is fixed.