I want to build an APk in Android Studio. If I run the project normally(Run/Run App), there is no problem and I get BUILD-SUCCESSFUL(with some errors). But when I want to build APK through Run/Build APK, unfortunately I get BUILD-FAILED and the following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/sun/activation/registries/LineTokenizer.class
Here is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId 'com.exp.Artoosh'
minSdkVersion 19
targetSdkVersion 24
versionCode 3
versionName "0.4.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
packagingOptions {
exclude 'META-INF/mimetypes.default'
exclude 'META-INF/mailcap.default'
}
}
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:multidex:1.0.1'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'javax.mail:mail:1.4.7'
compile 'com.sun.mail:android-activation:1.5.6'
testCompile 'junit:junit:4.12'
}
Could you please help me and tell me a solution?
I solved it.
The problem is that I used javax.mail and com.sun.mail together. First one is belongs java and second one belongs Android. I deleted javax.mail and added com.sun.mail instead, as you see in the following:
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:multidex:1.0.0'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'com.sun.mail:android-mail:1.5.6'
compile 'com.sun.mail:android-activation:1.5.6'
testCompile 'junit:junit:4.12'
}
run this in terminal
./gradlew clean
or
run Build/Clean Project
Related
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "[ MY PACKAGE ]"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
android {
useLibrary 'org.apache.http.legacy'
}
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.squareup.picasso:picasso:2.5.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.github.deano2390:android-viewbadger:1.0.0'
compile('com.jakewharton:butterknife:8.6.0') {
exclude module: 'support-compat'
}
compile project(':Library_MobilePaymentSDK')
testCompile 'junit:junit:4.12'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.github.aakira:expandable-layout:1.4.2#aar'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.android.gms:play-services:10.0.0'
compile 'com.google.firebase:firebase-messaging:10.0.0'
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'rongi.rotate-layout:rotate-layout:2.0.0'
compile 'com.roomorama:caldroid:3.0.1'
compile 'com.maksim88:PasswordEditText:v0.9'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jcmore2.appcrash:appcrash:1.1.0'
compile 'com.github.stfalcon:smsverifycatcher:0.2'
compile 'com.github.javiersantos:BottomDialogs:1.2.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
compile files('libs/mpaysdk-sandbox-1.0.28.jar')
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'
this gradle file works in api 21 but when i run on api 19 the following error occured.
the following error occured:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: n.class
plz help me to solve this problem.
Solution#1:
In terminal, You can execute the following command in your root project folder:
./gradlew clean
Solution#2:
If you use Android Studio, then you can do it easily, Go to Menu
Build/Clean Project
It will update old dependencies
Solution#3:
You can add the following section to your build.gradle file:
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
When I'm trying to build my app it's building process is stopped showing the following message in logcat it's showing error
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/lucasr/twowayview/BuildConfig.class
My build.gradle file is
android {
compileSdkVersion 25
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "community.infinity"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
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:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:support-v4:25.3.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.adamstyrc.cookiecutter:cookie-cutter:1.0.2'
compile 'com.allattentionhere:fabulousfilter:0.0.3'
compile 'com.github.florent37:diagonallayout:1.0.6'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.github.developer-shivam:FeaturedRecyclerView:1.0.0'
compile 'com.xujinyang.BiuEditText:library:1.4.1'
compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
compile 'gun0912.ted:tedbottompicker:1.0.12'
compile 'com.github.nkzawa:socket.io-client:0.5.2'
compile group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile 'org.lucasr.twowayview:core:1.0.0-SNAPSHOT#aar'
compile 'org.lucasr.twowayview:layouts:1.0.0-SNAPSHOT#aar'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
You are using the SNAPSHOT version :
compile 'org.lucasr.twowayview:core:1.0.0-SNAPSHOT#aar'
compile 'org.lucasr.twowayview:layouts:1.0.0-SNAPSHOT#aar'
and the STABLE version both at the same time
compile 'org.lucasr.twowayview:twowayview:0.1.4'
Try removing any of them. You should only use one at a time.
Visit:
https://github.com/lucasr/twoway-view
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
It occurs this error.
The app builds success but when I get build apk, android studio show this message
This is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25'
defaultConfig {
applicationId "com.example.thewell_dev.fourscompany"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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:23.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.koushikdutta.ion:ion:2.1.9'
compile 'gun0912.ted:tedpermission:1.0.2'
compile 'com.android.support:design:22.+'
compile 'com.estimote:sdk:0.13.0'
compile 'jp.wasabeef:glide-transformations:2.0.0'
compile 'com.afollestad:easyvideoplayer:0.3.0'
compile 'com.github.jrvansuita:PickImage:v2.0.0'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.mindorks:placeholderview:0.6.0'
compile 'com.tsengvn:Typekit:1.0.0'
compile 'com.github.esafirm:RxDownloader:1.0.1'
compile 'com.mlsdev.rximagepicker:library:1.1.2'
compile 'io.reactivex:rxjava:1.0.14'
compile 'com.kbeanie:image-chooser-library:1.5.2#aar'
compile 'com.kbeanie:image-chooser-library:1.5.8'
compile 'io.github.jeancsanchez.photoviewslider:photoviewslider:1.2.0'
compile 'com.nononsenseapps:filepicker:3.1.0'
compile 'com.gjiazhe:scrollparallaximageview:1.0'
compile 'com.droidninja:filepicker:1.0.8'
compile 'com.android.support:multidex:1.0.0'
}
I think external libraries have
Commons-io-1.3.2.jar
Commons-io-2.4.jar
and both have CopyUtils.class
Anyway, It can't build apk and show that message.
Please anyone help me please
There is more than one dependency you have integrated which uses Apache Commons.
just exclude them using following code in gradle.
compile('YOUR_DEPENDENCY') {
exclude module: 'commons-io'
}
Found the solution for this issue . You need to exclude common-io from your app build.gradle .
android {
configurations{
all*.exclude module: 'commons-io'
}
}
Techierj answer is correct, but it will also exclude commons-io:2.4, and in my case I needed that. So you can exclude by specific group:
compile('YOUR_DEPENDENCY') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
This will only exclude version 1.3.2 from org.apache.commons, and will mantain commons.io:commons.io:2.4
Error:(41, 13) Failed to resolve: com.google.android.gms:play-services-appindexing:10.0.1
Here is my build.gradle file of my project in Android Studio, the errors has came suddenly.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.pandey.nidhiiot"
minSdkVersion 16
targetSdkVersion 25
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'
}
}
}
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.google.android.gms:play-services:10.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.firebase:firebase-appindexing:10.0.0'
testCompile 'junit:junit:4.12'
apk 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:25.1.1-beta1'
// Glide image library
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.android.gms:play-services-appindexing:10.0.1'
}
apply plugin:'com.google.gms.google-services'
Referring to this post, you should remove
compile 'com.google.android.gms:play-services-appindexing:10.0.1'
since using the new library dependency (below) should be enough.
compile 'com.google.firebase:firebase-appindexing:10.0.0'
I copied the part of your gradle file for dependencies and encountered the same. After removing the duplicate (compile 'com.google.android.gms:play-services:10.0.1') and replacing the dependency as mentioned above, the build was successful.
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.github.bumptech.glide:glide:3.7.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
testCompile 'junit:junit:4.12'
apk 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:25.1.1-beta1'
// Glide image library
compile 'com.github.bumptech.glide:glide:3.7.0'
}
You have
compile 'com.google.firebase:firebase-appindexing:10.0.0'
compile 'com.google.android.gms:play-services-appindexing:10.0.1'
Check if just one of them is necessary.
Also check changing firebase-appindexing to 10.0.1
Try this may be helpful
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.pandey.nidhiiot"
minSdkVersion 16
targetSdkVersion 25
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'
}
}
}
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.google.android.gms:play-services:10.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.firebase:firebase-appindexing:10.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-appindexing:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.android.support:support-v4:25.1.0'
testCompile 'junit:junit:4.12'
// Glide image library
compile 'com.github.bumptech.glide:glide:3.7.0'
}
apply plugin:'com.google.gms.google-services'
For some reason, I am getting a strange error after adding Retrofit to a project that I inherited. If I remove Retrofit, the project builds but If I add it back then the error will re-appear.
How can I fix this issue? any suggestion is welcomed.
Here is the gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.domain.appname"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-config:10.0.1'
compile 'com.google.firebase:firebase-invites:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.firebaseui:firebase-ui:1.0.1'
compile 'com.firebase:geofire-android:2.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.karumi:dexter:2.3.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-simplexml:2.1.0'
}
And here is a screenshot of the error message that I am getting.
https://dl.dropboxusercontent.com/u/15447938/downloads/gradle_error.png
I ran gradlew app:dependencies and it was pointing to "UnsupportedClassVersionError"
Caused by: java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:71)
at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:51)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
This turns out to be some transitive dependencies that Simple XML converter have on Android core. I fixed the issue per this StackOverflow question like this
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.1.0'){
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}