Im using lib Gson in my dependecies and im import a .aar with some classes from Gson that are imported to a project. When i build my project i keep getting duplicated classes, bcz its on my dependency and aar classes.
How i can exclude gson classes from aar?
I have been trying with:
Can i do it? or should i get other .aar with gson as dependecy?
unzip original_lib.aar -d out/
cd out/
zip -d classes.jar "com/something/ClassToBeRemoved.class"
jar cvf ../my_new_lib.aar
Now you have a new AAR library file named my_new_lib.aar, which excludes the specified class file.
You can include local .aar library in Gradle using:
implementation files('aar/my_new_lib.aar')
Remember to replace "com/something/ClassToBeRemoved.class" with the actual path and name of the class file you want to exclude. Also, ensure that you are in the correct directory when executing these commands.
This approach allows you to manually remove specific class files from an AAR library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With