Gradle assembleRelease doesn't work with ProGuard - java

So my project seemed to break at random today, with the error apparently being something about being over 65K methods. After doing some research I realised it was time to use ProGuard and enable multiDex, which seemes to have made things worse. This is the error I get when I try create a release APK:
Error:Execution failed for task
':My-Project:proguardRelease'.
java.io.IOException: Can't write [C:\Users\User-PC\AndroidStudioProjects\MyProject\My-Project\build\intermediates\classes-proguard\release\classes.jar] (Can't read [C:\Users\User-PC\AndroidStudioProjects\MyProject\My-Project\libs\bolts-android-1.2.0.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [a/a.class == bolts-android-1.2.0.jar:bolts/AggregateException.class]))
and my build.gradle file looks like this:
apply plugin: 'com.android.application'
apply plugin: 'com.parse'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.parse.com/repo' }
}
dependencies {
classpath 'com.parse.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(include: 'ParseCrashReporting-*.jar', dir: 'libs')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.github.dkharrat.nexusdialog:nexusdialog:0.2.0'
}
android {
signingConfigs {
config {
// stuff
}
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.kusasa.saleboat"
minSdkVersion 19
targetSdkVersion 21
versionCode 8
versionName "1.0.7"
// Enabling multidex support.
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
productFlavors {
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
debuggable false
}
}
}
I have tried cleaning and rebuilding the project several times, to no avail.

Well i think you get this error because you declare two dependencies of bolts-android one in My-Project\libs\bolts-android-1.2.0.jar the other usinge maven with compile 'com.parse.bolts:bolts-android:1.+'
Remove the lib that's on the lib folder.

Related

Java and Kotlin combined build error (Duplicate Zip Entry)

I have added Kotlin library to my existing project. After that I'm getting the build error. I commented all the recently added libraries and checked the main problem is after adding kotlin library
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can't read [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/transforms/desugar/debug/76.jar(;;;;;;**.class)] (Duplicate zip entry [76.jar:org/intellij/lang/annotations/Flow.class]))
Project gradle
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath ('com.google.firebase:firebase-plugins:1.0.5') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
}
}
allprojects {
repositories {
google()
jcenter()
maven {url "https://maven.google.com"}
}
}
And the app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'com.example.android'
minSdkVersion 20
targetSdkVersion 27
versionCode 17
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
buildConfigField("String", "BASE_URL", "\"url\"")
buildConfigField("String", "API_KEY", "\"key\"")
}
}
productFlavors {
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '.readme'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':controllers')
compile files('libs/achartengine-1.2.0.jar')
compile files('libs/dfuLibrary.jar')
compile 'com.android.support:appcompat-v7:27.0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.polidea.rxandroidble:rxandroidble:1.0.2'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.jakewharton:butterknife:8.8.1'
testCompile 'junit:junit:4.12'
/*compile 'org.hashids:hashids:1.0.3'
compile 'com.google.dagger:dagger:2.11'
compile 'javax.inject:javax.inject:1'
kapt 'com.google.dagger:dagger-compiler:2.11'
compile 'io.reactivex.rxjava2:rxjava:2.1.3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.amitshekhar.android:rx2-android-networking:1.0.0'
compile 'com.android.support:multidex:1.0.2'*/
}
apply plugin: 'com.google.gms.google-services'
If I remove the below line from the app gradle everything works fine. But if I add the kotlin library I'm getting the error.
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
How can I use the kotlin and Java together.
Atlast I found the answer, it was due to duplicate entry to annotation which can be solved by using the below lines in the gradle.
configurations {
compile.exclude group : 'org.jetbrains' , module : 'annotations'
}

ZipException: duplicate entry exception

I'm making Android chat bot app with Firebase and API.AI.
After adding firebase UI lib to project, I got java.util.zip.ZipException: duplicate entry runtime exception.After that, I've added javaMaxHeapSize = "4g" but could not find a solution for this.Tried with different FirebaseUI versions, but none of them worked.
There are other similar questions, but each is generic with different build.grade.
Here is message:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class
Gradle files:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.bot.chatbot.chatbot"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
dexOptions {
javaMaxHeapSize = "4g"
}
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'
})
//Google
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//AI
compile 'ai.api:sdk:2.0.7#aar'
compile 'ai.api:libai:1.4.8'
compile 'com.google.code.gson:gson:2.3.1'
compile 'commons-io:commons-io:2.4'
//Firebase
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-storage:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.firebaseui:firebase-ui:0.4.3'
compile 'com.firebaseui:firebase-ui-database:2.3.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Second one :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is happening because you are mixing the old dependencies with new ones. So in order to solve your problem, delete the following line of code from your build.gradle file.
compile 'com.firebaseui:firebase-ui-database:2.3.0'
This line of code is no needed and that's why you get duplicate entry exception. See the version compatibility for the FirebaseUI i suggest you see the offical documentation.

update google services from 9.0.0 to 10.0.1 Android studio 2.2

I get an error saying
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.
I tried looking at https://bintray.com/android/android-tools/com.google.gms.google-services/ and com.google.gms:google-services:3.0.0 seems to be the latest. This is my project gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.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
}
And this is how my app gradle looks like
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "sk.tipos.paradox02.citaj"
minSdkVersion 11
targetSdkVersion 23
versionCode 27
versionName '2.003'
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
debug {
debuggable true
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
// signingConfig signingConfigs.release
}
}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
If I change the play services to 9.0.0 everything compiles fine. What am I missing here?
Have you idea how resolve problem?
Thanks
You are having this issue because Firebase was built using Google Play Services , so you can't use a version of Google Play Services higher than the version of Firebase.
Can you try :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "sk.tipos.paradox02.citaj"
minSdkVersion 11
targetSdkVersion 23
versionCode 27
versionName '2.003'
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
debug {
debuggable true
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
// signingConfig signingConfigs.release
}
}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'
Sorry for my english, hope it's help.
You are using different versions of dependencies.Update their version to match version of latest google services version.
e.g.
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-appindexing:10.2.0'
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
Have you tried the solution given in this post: https://stackoverflow.com/a/37565535/3108709 . I had the same issue as you had, this solved it for me.
That's because you should always put the "apply plugin" clause at the bottom for google-services, since it looks for the already-added dependencies. Do it like this in your app-level gradle:
dependencies {
compile 'com.google.android.gms:play-services-ads:9.0.1'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
This is hidden in the Firebase documentation, but applies even if you don't use Firebase.
Note : Update Google Repository also.

Duplicate files copied in APK AUTHORS

I have this problem when i will to compile my project:
And when i will build my project to APK i have this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/objectweb/asm/tree/AbstractInsnNode.class
This is my gradle.
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "come.texi.driver"
minSdkVersion 16
targetSdkVersion 23
versionCode 2
versionName "2.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// compile 'com.jakewharton:butterknife:7.0.1'
//compile 'com.loopj.android:android-async-http:1.4.9'
compile project(':facebooklibrary')
compile project(':slideMenuLibrary')
compile project(':stripe')
compile('com.twitter.sdk.android:twitter:1.13.0#aar') {
transitive = true
}
//compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile('io.socket:socket.io-client:0.7.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
//compile 'com.paypal.sdk:paypal-android-sdk:2.14.4'
compile('com.paypal.sdk:paypal-android-sdk:2.14.4') {
exclude group: 'org.json', module: 'json'
}
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'cz.msebera.android:httpclient:4.4.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.victor:lib:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.tools.build:gradle:2.2.3'
testCompile 'junit:junit:4.12'
}
Help me!!
I had the exact same problem, except I am using Android Gradle Plugin 2.3.3, but that's not the issue. Here is how I solved it, hope this will help you.
Inside android, add the packagingOptions to exclude AUTHORS like this:
android {
packagingOptions {
exclude 'AUTHORS'
}
}
Here is some documentation reference

java.util.zip.ZipException: duplicate entry support v4 PrintHelper$1.class

I am not sure what this error means.
Error:Execution failed for task': eCampus : packageAllDefaultFlavorDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$1.class
my bulid.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "tw.edu.chu.ecampus"
minSdkVersion 11
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
repositories {
mavenCentral()
}
dependencies {
compile project(':G0.10.ABS')//ActionBarSherlock
compile project(':vitamio')
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.android.support:multidex:1.0.1'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
}
Error does not show up during gradle sync. Just when I try to run the application
What could be the problem?
I meet the same error, and I solve it, but I just give u that my case;
my bulid.gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ('com.android.support:appcompat-v7:22.0.0')
compile files('libs/android-async-http-1.4.8.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/universal-image-loader-1.9.4-with-sources.jar')
}
the error for is the com.android.support:appcompat-v7:22.0.0 include the support-v4.jar, so I remove it;
solve build.gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ('com.android.support:appcompat-v7:22.0.0') {
exclude module: 'support-v4'
}
compile files('libs/android-async-http-1.4.8.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/universal-image-loader-1.9.4-with-sources.jar')
}
so maybe u should check ur dependencies, maybe ur compile files have two files include support-v4

Categories

Resources