getting error when trying to get APK file of android project - java

so I was trying to generate the APK file of an android project created in Android Studio and I keep getting the following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/concurrent/Cancellable.class
also here's my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.app"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(':vitamio')
compile 'com.android.support:appcompat-v7:24.0.0-beta1'
compile 'com.google.android.gms:play-services:9.0.1'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.android.support:design:24.0.0-beta1'
compile 'com.github.natasam:DemoProgressViewsLibApp:fa2f8f01e0'
compile 'com.google.android.gms:play-services-ads:9.0.1'
compile 'com.google.android.gms:play-services-auth:9.0.1'
compile 'com.google.android.gms:play-services-gcm:9.0.1'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
}
So can any one please tell me how I can solve that error ? I tried removing the http in dependencies but still error. Any respond is appricated. Thanks!

Related

Error during Building an APK file in Android Studio

I was trying to build an apk for my project but i am facing this error and
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.dex.DexException:
Multiple dex files define Lcom/google/android/gms/internal/zzajl;
i also added multiDexEnabled true but still getting error
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
com/google/android/gms/internal/zzaix.class
Below is my Build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "in.package.name"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
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 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-ads:11.0.1'
testCompile 'junit:junit:4.12'
// Adding support library for this demo app
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-database:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
Please suggest me some solution
Thanks
Use SAME version
compile 'com.google.android.gms:play-services-ads:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
Then Clean-Rebuild and Restart IDE .
Try cleaning the project first - ./gradlew clean

java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzak.class

im working with android,
When the gradle syncs works good, but if I try to compile show me this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzak.class
Follow the another answers in here and here ,
if I delete google play services, result its same.
But the result its same, my gradle:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.procibernetica.moca"
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(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'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-auth:9.6.1'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.google.firebase:firebase-database:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-auth:9.6.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.github.satyan:sugar:1.5'
compile 'com.android.support:design:25.3.1'
compile 'org.msgpack:msgpack:0.6.11'
compile 'com.theneura:android-sdk:+'
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2#aar') {
transitive = true
}
compile project(':moca-sdk-android-1.9.6')
testCompile 'junit:junit:4.12'
}
Follow the tutorial:
https://developers.google.com/android/guides/setup
I remove:
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
compile 'com.google.android.gms:play-services-auth:9.6.1'
And change for:
compile 'com.google.android.gms:play-services:10.2.4'
And works

Getting error "Execution failed for task ':app:transformClassesWithDexForDebug"

Need help.
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.dex.DexException: Multiple dex files define Lcom/google/android/gms/inte
The application runs on api level 23 but gives the above error for api 16 which is my minsdk.
my gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.raghavkishan.financialplanner"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
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 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Thanks.
First clean project and rebuild,then add following code in your project's app level build.gradle file:
defaultConfig {
multiDexEnabled true
}
In your build.gradle file,
dependencies contains following lines:
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
Instead this change to following lines:
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
just make sure each version have same values.

Could not find support-v4.aar(com.android.support:support-v4:24.1.1)

The project is one of Google samples on Github, Androidtv-Leanback. I cloned it and opened with Android studio, but build fails.
Error:
Could not find support-v4.aar(com.android.support:support-v4:24.1.1)
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24'
defaultConfig {
applicationId "com.example.android.tvleanback"
minSdkVersion 21
targetSdkVersion 24
versionCode 2
versionName "1.3"
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'])
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:leanback-v17:24.1.1'
compile 'com.android.support:recommendation:24.1.1'
compile 'com.android.support:preference-leanback-v17:24.1.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.robolectric:robolectric:3.1'
androidTestCompile 'com.android.support:support-annotations:24.1.1'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
compile 'com.google.android.exoplayer:exoplayer:r1.5.8'
// compile files('src/libs/android-support-v4.jar')
}
add this dependency in your build.gradle file
dependencies {
...
compile "com.android.support:support-v4:24.2.1"
}
and make sure you have downloaded the android support repository using sdk manager.

Error:Execution failed for task ':app:preDexDebug'. > ... finished with non-zero value 1

I add a library to my project,but the library has some jar packages that i have used in my app,so it comes out the error "finished with non-zero value 2",after i modify the jar packages version,it comes out the error "Error:Execution failed for task ':app:preDexDebug'. > ... finished with non-zero value 1",i dont konw how to solve it 。
the app buidle.gradle :
`apply plugin: 'com.android.application'
android {
packagingOptions{
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.fengmanlou.logintest"
minSdkVersion 14
targetSdkVersion 21
versionCode 2
versionName "2.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.0.0'
compile project(':slibingtab')
compile project(':leanchatlib')
compile files('libs/weibo.sdk.android.sso.jar')
compile files('libs/Java-WebSocket-1.2.0-leancloud.jar')
compile files('libs/qq.sdk.1.6.1.jar')
compile files('libs/httpmime-4.2.4.jar')
compile files('libs/fastjson-1.1.37-leancloud.jar')
compile files('libs/avoscloud-statistics-v3.1.1.jar')
compile files('libs/avoscloud-sdk-v3.1.4.jar')
compile files('libs/avoscloud-push-v3.1.4.jar')
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/android_api_1.1_forsdk.jar')
compile files('libs/BaiduLBS_Android.jar')
compile files('libs/galaxy_mini.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/avoscloud-sns-v3.1.1.jar')
compile files('libs/avoscloud-search-v3.1.1.jar')
compile files('libs/weibosdkcore.jar')
compile files('libs/litepal.xml-1.2.0.jar')
compile project(':pulltorefresh')
compile files('libs/avoscloud-feedback-v3.1.1.jar')
compile files('libs/jsoup-1.8.1.jar')
compile project(':slibingmenu')
} `
the library build.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.0.0'
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/avoscloud-push-v3.1.4.jar')
compile files('libs/avoscloud-sdk-v3.1.4.jar')
compile files('libs/butterknife-6.1.0.jar')
compile files('libs/eventbus-2.4.0.jar')
compile files('libs/fastjson-1.1.37-leancloud.jar')
compile files('libs/httpmime-4.2.4.jar')
compile files('libs/Java-WebSocket-1.2.0-leancloud.jar')
compile files('libs/prettytime-3.2.5.Final.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
}
this is the first time i use stackoverflow to ash question,please tell me how to solve it .thank you!
I also dont know how to solve the problem.but the project is built successfully.There is a jar package that cant be opened. I delete it and add the jar package from other project.it works.

Categories

Resources