Exclusion of some modules from proguard Android Gradle Buildscript

I have a project structure like this:

Root Project +------ Module A +------ Module B Now module B is a huge project, but I use the API to access it, so I would like to load the classes of module B at runtime. Therefore, I would like to compile it, but in a separate DEX file. I can compile a separate DEX file as follows:

https://gist.github.com/nickcaballero/7045993

In debug compilation mode, this works great, since you can change libraries that are DEXED via buildscript in this form

 def libraryFiles = new ArrayList<?>() variant.dex.libraries.each { File file -> // Exclude Module B from Dex library list if (!file.absolutePath.contains("ModuleB/unspecified/classes.jar")) { libraryFiles.add(file); } } variant.dex.libraries = libraryFiles 

Now it works well, since without executing proguard, AndroidBuilder simply uses variant.dex.libraries to create a DEX file and simply excludes it. Pain occurs when you need to make an intermediate class prologue. Since ModuleB is a compile-time dependency (for resource / layout integration purposes, etc.), therefore its classes are compiled into the assembly directory.

However, when this happens, the default proguard function defined in Android Builder throws classes.jar as libraryJars into the file.

At the end of this job, classes-proguard is created that contains all the classes from the above Jars libraries. Then it gets DEXED, and the classes that were supposed to be loaded through Runtime are present in it. Is there a way to exclude certain banks so that they do not fall into the default proguard task?

+6
source share

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


All Articles