java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class - android-studio

I migrated my project from eclipse to Android Studio,When I'm trying to run my app,I am getting following issue
':transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.le.SampleApp"
minSdkVersion 11
targetSdkVersion 23
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
aaptOptions
{
cruncherEnabled = false
}
useLibrary 'org.apache.http.legacy'
}
configurations {
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
dependencies {
compile project(':_library')
compile project(':drag_library')
compile project(':library_pull')
compile 'com.android.support:support-v4:23.+'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.google.guava:guava:18.0'
compile 'joda-time:joda-time:2.2'
compile 'com.android.support:appcompat-v7:23.+'
compile files('libs/google-http-client-1.13.1-beta.jar')
compile files('libs/google-http-client-android-1.15.0-rc.jar')
compile files('libs/google-play-services.jar')
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/amazinglistview.jar')
compile files('libs/android-viewbadger.jar')
compile files('libs/commons-io-1.3.2.jar')
compile files('libs/commons-lang3-3.1.jar')
compile files('libs/crashlytics.jar')
compile files('libs/d2xx.jar')
compile files('libs/iHealthLibrary_2.2.8.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/paho-mqtt-client-1.0.1.jar')
compile files('libs/pl2303driver.jar')
compile files('libs/robospice-1.4.11.jar')
compile files('libs/robospice-cache-1.4.11.jar')
compile files('libs/robospice-google-http-client-1.4.11.jar')
compile files('libs/rtcc-5.4.730.jar')
compile files('libs/samsung_ble_sdk_200.jar')
compile files('libs/universal-image-loader-1.9.3-with-sources.jar')
compile files('libs/volley.jar')
}
Any advice on how i could resolve this issue?

Related

Android studio APK buil error transformClassesWithJarMergingForDebug

I'm trying to build APK, but there is an error when I try to make it.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/PendingCallback.class
Following is my build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "jordan.personicle"
minSdkVersion 19
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(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/ajt-2.9.jar', 'libs/javaml-0.1.7.jar')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services:11.0.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'org.jsoup:jsoup:1.7.3'
compile 'com.android.support:multidex:1.0.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
This is my build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// 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
}
I think there is no duplication for gcm. What is the problem?
Thanks,
Make sure you use the same version in all your google play services libs:
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
See https://stackoverflow.com/a/42610163/1370087

Create APK file of automation script using Android Studio

after put appium 'java-client' dependencies in android studio not build .apk what i do please tell me
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
dexOptions {
incremental true
jumboMode = true
// preDexLibraries = false
}
defaultConfig {
applicationId "com.example.ignatiuz.photoboothapplication"
minSdkVersion 15
targetSdkVersion 25
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'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
repositories {
jcenter()
mavenCentral()
}
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 'io.appium:java-client:3.4.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'commons-logging:commons-logging:1.2'
// compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
compile 'org.apache.httpcomponents:httpcore:4.4.6'
testCompile 'junit:junit:4.12'
compile files('libs/commons-logging-1.2.jar')
compile files('libs/httpclient-4.5.3.jar')
compile files('libs/httpcore-4.4.6.jar')
}
and my jar detail
and my error
Error Text
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: net/sf/cglib/beans/BeanCopier$BeanCopierKey.class
You can use gradle to import all the dependencies that you need instead of adding them in /libs folder
These are the dependencies I'm having in build.gradle for connecting and running Appium tests.
compile 'junit:junit:4.12'
compile 'io.appium:java-client:4.1.2'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'commons-lang:commons-lang:2.6'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.http-client:google-http-client:1.21.0'
compile 'com.testdroid:testdroid-api:2.9'
compile 'com.google.http-client:google-http-client-jackson2:1.21.0'

Gradle error while Importing project from eclipse to studio

i am trying to importing my eclipse project to Android studio.SO i removed all my GCM code and create code for FCM. But when i creating Build APK it shows me following error like
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
My gradle file contains following dependencies and libraries.
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "mi.nashik.online"
minSdkVersion 15
targetSdkVersion 23
versionCode 16
versionName "1.9.6"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile ('com.android.support:appcompat-v7:23.4.0')
{
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'com.android.support'
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.google.android.gms:play-services:9.0.2'){
exclude group: 'com.android.support'
exclude group: 'com.google.guava'
}
compile 'com.google.code.gson:gson:2.1'
compile 'com.google.protobuf:protobuf-java:2.2.0'
compile files('libs/google-api-client-1.10.3-beta.jar')
compile files('libs/google-api-client-android2-1.10.3-beta.jar')
compile files('libs/google-http-client-1.10.3-beta.jar')
compile files('libs/google-http-client-android2-1.10.3-beta.jar')
compile files('libs/google-oauth-client-1.10.1-beta.jar')
compile files('libs/jackson-core-asl-1.9.4.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/library-1.2.2.jar')
compile 'com.squareup.picasso:picasso:2.5.0'
compile files('libs/slider.jar')
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-analytics:9.0.2'
compile ('com.google.firebase:firebase-core:9.0.2')
{
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile ('com.google.firebase:firebase-messaging:9.0.2'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile files('libs/universal-image-loader-1.9.3-SNAPSHOT.jar')
compile files('libs/urlimageviewhelper-1.0.4.jar')
}
apply plugin: 'com.google.gms.google-services'
Update your gradle.properties file by
org.gradle.jvmargs=-Xms256m -Xmx1024m

Gradle doesn't load 0.9.8 version library

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.user.myapplication"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java/2', 'src/main/java/com/example/user/myapplication/function']
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.androidplot:androidplot-core:0.9.8'
}
this is my code.
Gradle doesn't load 0.9.8 version library. However when I use 0.6.1 library it can load. I want to use latest version. What's the problem?
For anyone for whom updating did not work, when I had this problem I discovered that it was because I did not have
mavenCentral()
in the project level build.gradle file (under allprojects and repositories).

VerifyError Exception on Android Studio

I'm running my app on Android Studio 1.3.2, and getting an exception that I can't get through. I've been searching on google for hours and didn't find the solution.
java.lang.VerifyError: org/apache/http/conn/ssl/DefaultHostnameVerifier
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:944)
at com.romi.expensemanager.OCRServiceAPI.sendImage(OCRServiceAPI.java:62)
at com.romi.expensemanager.OCRServiceAPI.convertToText(OCRServiceAPI.java:44)
at com.romi.expensemanager.Main$1.run(Main.java:68)
at java.lang.Thread.run(Thread.java:856)
I add external jars:
httpclient-4.5.jar, httpcore-4.4.1.jar, httpmime-4.5.jar.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.romi.expensemanager"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/picasso-2.5.2.jar')
compile project(':httpclient-4.5')
compile project(':httpcore-4.4.1')
compile project(':httpmime-4.5')
}
Any help will be appreciated. Thanks.

Resources