0



I am having my android studio project with four library modules and one application module in it.
I am having six jar files which I have kept in one directory. Each of these modules are using some of the jar files. So I have added dependencies of these jars in build.gradle file of respective module with relative path using "compile files('./../../deliverables/xyz.jar')". Application module is dependent on all these library modules. When I create release build of my application module, it fails with "duplicate zip entry" error of proguard as I have enabled proguard in gradle build script. This error is for six jar files.

The debug build of this project is working fine.

I tried below solutions:
1. injar option in proguard-rules.pro file
2. dontwarn option in proguard-rules.pro file
3. keep option in proguard-rules.pro file


Please help me.


Thanks.

Swati
  • 419
  • 1
  • 4
  • 6
  • I believe you are experiencing the issue described here: http://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk – AgileNinja Apr 26 '16 at 15:08
  • I tried the solutions provided at above link but are not working for me. My issue is exactly like https://groups.google.com/forum/#!topic/adt-dev/HwSrdvPW7Fc – Swati Apr 27 '16 at 05:31

1 Answers1

0

One solution is to create a libraries module whose sole purpose is to contain the .jar files. Once all the jar files that you need are in this module, you can remove them from the other modules and reference your library module in your other modules.

For example, let's say we have the app module depend on these four modules:

app
|---module1
|---module2
|---module3
|---module4

We can create a libraries module that you will reference in the modules that use at least one of the libraries contained in the module, by adding the following to the module's build.gradle:

compile project(':libraries')
AgileNinja
  • 914
  • 1
  • 7
  • 20
  • Thanks for solution, it works. But my app is having flavors in which each flavor contains different set of modules, so I don't want library source in apk if respective module is not included, that's why added dependency of lib in respective module only. So I want to know how proguard includes jars or android appcompact libs in build process. – Swati Apr 28 '16 at 05:38
  • @Swati sorry, missed your comment. You can have two library modules (`libraries` and `libraries-paid`) where the paid version is only referenced in the module that is in the paid flavor (or whatever flavor you have). – AgileNinja May 14 '16 at 13:54