(Duplicate zip entry [coolLib.jar: {pkg} /BuildConfig.class]))

I have an Android project in Android Studio 2.3.0 beta4 , which depends on the CoolLib library project .

CoolLib has its source in the jar file coolLib.jar in the libs folder. coolLib.jar contains the file {pkg} /BuildConfig.class .

When I try to create and run a project on a device / emulator in Android API-22 +, it works fine, but when I try to do the same on a device / emulator in API VERSION <22, Android Studio cannot build using an exception -

Warning: exception during processing java.io.IOException: cannot write [D: \ AndroidStudioProjects \ CoolProject \ app \ build \ intermediates \ transforms \ proguard \ debug \ jars \ 3 \ 1f \ main.jar] (Unable to read [D: \ AndroidStudioProjects \ CoolProject \ CoolLib \ build \ intermediates \ bundles \ default \ libs \ coolLib.jar (;;;;;;; **. Class)] (Duplicate zip entry [coolLib.jar: {PKG} /BuildConfig.class] )): app: transformClassesAndResourcesWithProguardForDebug FAILED

The build.gradle project contains the following versions of lib support, etc.

ext { supportLibVer = '25.1.1' playServiceVer = '10.0.1' buildToolsVer = "25.0.2" compileSdkVer = 25 targetSdkVer = 25 minSdkVer = 16 } dependencies { compile files('libs/FLurry_3.2.2.jar') compile files('libs/jxl-2.6.12.jar') compile project(':CoolLib') compile files('libs/gcm.jar') compile "com.google.android.gms:play-services-ads:$playServiceVer" compile "com.android.support:appcompat-v7:$supportLibVer" compile "com.android.support:design:$supportLibVer" compile "com.android.support:cardview-v7:$supportLibVer" compile "com.android.support:support-v13:$supportLibVer" compile 'com.github.bumptech.glide:glide:3.7.0' } 
+5
source share
1 answer

Ok, I got a solution.

Why -

I compared the build steps in the gradle console in API22 (build OK) and API16 (build failures). In API22, the console said -

+ Instant Run: Proguard is not compatible with instant start. It is disabled for debugging.

+ Instant Run: resource smoothing is automatically disabled for debugging

.. and the assembly was successful. When I disabled InstantRun, it also failed in API22.

The reason is

The problem was the configuration of proguard. BuildConfig.class coolLib.jar was defined as contained in proguard-project.txt , so it kept all .class in this package, but BuildConfig.class needed to be changed at build time according to the main project.

Decision -

I removed the -keep statement and works like a charm.

+2
source

Source: https://habr.com/ru/post/1264076/


All Articles