When I try to generate Signed APK, I am getting the following error
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class
The Debug APK is working perfectly. After I include Facebook SDK then only I am facing this issue... Can anyone help me how to solve this issue
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.5'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "mani.com.howhighru"
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'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
testCompile 'junit:junit:4.12'
compile('com.twitter.sdk.android:twitter:2.3.1#aar') {
transitive = true;
}
}
Related
I have an error in my gradle:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [C:\Users\El-Othmane\Desktop\tes11\android2\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\El-Othmane.gradle\caches\transforms-1\files-1.1\support-core-ui-26.1.0.aar\744d5e6087e939bc5d55ea9f4d6a237d\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [classes.jar:android/support/v4/view/ViewPager$2.class]))
enter code here Here is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 14
targetSdkVersion 27
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
productFlavors {
}
}
dependencies {
compile('com.google.android.gms:play-services:+') { exclude module: 'support-v4' }
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
First add this library in Gradle:
compile 'com.android.support:multidex:1.0.0'
Also you can add multidex:
multiDexEnabled true
and make your application to extend class MultiDexApplication.
Put code like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 16
targetSdkVersion 25
versionCode 4
versionName "1.3"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
}
useLibrary 'org.apache.http.legacy'
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 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
}
apply plugin: 'com.google.gms.google-services'
You are talking about how to exclude V4 See
Instead of V4 you can put V7 also like this
compile 'com.android.support:appcompat-v7:25.4.0'
You got this error may be because of Prograurd Duplicate zip entry
check below Links1 , Links2
Hope this solved your problem.
The error is expected because you're using an old support library which is conflicted with your compileSdkVersion and Google play service. So, you need to change your build.gradle to something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 14
targetSdkVersion 27
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
productFlavors {
}
}
dependencies {
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
// Don't use the following
//compile files('libs/support-v4-19.0.1.jar')
// instead, use support library with the same version with your compileSdkVersion
compile 'com.android.support:support-v4:27.1.1'
// You should NOT use all the google play service
// use what you need, please refer to https://developers.google.com/android/guides/setup
compile 'com.google.android.gms:play-services:11.2.0'
}
I was getting this error:
Error:Execution failed for task ':app:preDebugBuild'.
Android dependency 'com.android.support:appcompat-v7' has different version for the compile (25.3.1) and runtime (27.1.0) classpath. You should manually set the same version via DependencyResolution
A quick search on google showed me that I should include in my app/build.gradle:
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "25.3.1"
}
}
Now I get a new error:
Could not get unknown property 'resolutionStrategy' for project ':app' of type org.gradle.api.Project.
here is my full app/build.gradle code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
dexOptions {
preDexLibraries = false
}
defaultConfig {
applicationId "co.test.Test"
minSdkVersion 26
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
flatDir {
dirs 'libs'
maven { url "http://dl.bintray.com/chat-sdk/chat-sdk-android" }
google()
maven { url "https://jitpack.io" }
mavenLocal()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':library')
implementation 'co.chatsdk.chatsdk:chat-sdk-core:4.0.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-ui:4.0.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-adapter:4.0.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-file-storage:4.0.8'
}
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "25.3.1"
}
}
apply plugin: 'com.google.gms.google-services'
my library/build.gradle:
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation files('libs/aacdecoder-android-0.8.jar')
}
I have a problem with Android Studio saying:
failed to resolve
com.google.code.ksoap2-android:ksoap2-android:3.6.1
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example.papiroomdemo.webservicetest"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
repositories {
maven { url 'http://ksoap2-android.googlecode.com/svn/m2-repo' }
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.hannesdorfmann.smoothprogressbar:library:1.0.0'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.0'
}
Error:(30, 13) Failed to resolve:
com.google.code.ksoap2-android:ksoap2-android:3.6.1 Show in FileShow in Project Structure
dialog
I think your url in repositories section is invalid. You should add
https://oss.sonatype.org/content/repositories/ksoap2-android-releases/:
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
}
More info here: http://simpligility.github.io/ksoap2-android/getting-started
/// add these lines in module gradle
allprojects {
repositories {
google()
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/'
}
}
}
I am new to Android and Android Studio so, I downloaded a project that I also need for my class then I got this error. I could not find my answer here, although there was a question like mine. Please help me to run this program that I downloaded from internet and solve this error, thank you.
These are my gradles:
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.gettaxi"
minSdkVersion 8
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
And:
// 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.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.stackoverflow.answer"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
androidTestCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
}
The error i got is:
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqr.class
I have been stuck for hours on this issue.
Here is my Build.Gradle (app file) .
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
buildscript {
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "org.my.app"
minSdkVersion 19
targetSdkVersion 23
versionCode 140
versionName "1.4.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:7.0.0'
// Android SDK
compile 'com.facebook.android:facebook-android-sdk:4.+'
// Audience Network SDK. Only versions 4.6.0 and above are available
compile 'com.facebook.android:audience-network-sdk:4.+'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'com.facebook.fresco:fresco:0.9.0+'
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.2#aar') {
transitive = true;
}
}
crashlytics {
enableNdk true
androidNdkOut 'src/main/obj'
androidNdkLibsOut 'src/main/libs'
}
You are adding the same class with different versions twice.
You are using the Google play services modules with different releases:
Use:
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'