I have a project that depends on some maven lib, after proguard I got the files under package com.xxx kept, but I didn't add the rule in my project proguard files, I must be imported from maven lib. I know there will be a merged proguard file during progurad processure. My question is there a way to hook the processure and prints the separated proguard rules, or how to find which lib imports the rule.
Thanks in advance.
Modify your proguard-project.txt to include
-printconfiguration "build/outputs/mapping/configuration.txt"
Trigger proguard run with ./gradlew assembleRelease and inspect the file. It doesn't always tell which aar or jar has contributed it though. Maybe create feature request for AGP to make behaviour consistent with aapt which prints where every line is coming from.
Related
I have an android library hosted on jitpack, but due to its dependencies requirements it is not built to and AAR file. It just a basic project that you can pull the methods from.
I want to hide the names for the classes, methods, and variables within the project itself without compilation. I understand that I could minify it in the gradle but that would only work once the project is built into and apk or bundle.
Is there a way to post process the code to have the same effect?
I have found the answer I was looking for. Jitpack pre-builds the project after you commit changes. In this compilation process it does take the minification in the gradle and proguard rules into account. Even though I don't distribute an AAR or Jar file, the code still gets hidden in the same way.
In conclusion, Just set up the minification and proguard rules as your normally would and Jitpack will handle the rest.
A project I'm working on contains a lot of external dependencies on 3rd party libraries. While analyzing compiled apk I found out that a package within the app that is supposed to be obfuscated remains clean. When I dived deeper I figured out that merged ProGuard configuration contains a rule breaking obfuscation logic.
None of the project's ProGuard configurations contain this rule. So I assume that it was gotten from one of the dependencies and merged to final configuration.
I look through this question but it seems that the answer is no longer valid for Android Plugin for Gradle 3.0.1 that I'm using because build/intermediates/exploded-aar folder no longer contains any ProGuard configurations.
So I'm wondering:
Is there a way to find what library causes the problem?
Is it still possible to disable a rule from consumer proguard file?
I am using a third party .aar project and they have enabled the proguard in the aar project. And in my Application Project i am enabling Proguard as well and its giving me errors.
So, do i need their(.aar project) proguard rules to be included in my proguard config files or is there any other possibility?
I have read in blogs and posts that the best approach is to include the .aar project without proguard and then run the proguard on aar and application project as a whole.
If i run proguard on Application will it affect the imported library's(already proguarded) code ?
So, do i need their(.aar project) proguard rules to be included in my proguard config files or is there any other possibility?
Quoting the documentation:
You can enable code shrinking on your library by adding a ProGuard configuration file to your library that includes its ProGuard directives. The build tools embed this file within the generated AAR file for the library module. When you add the library to an app module, the library's ProGuard file gets appended to the ProGuard configuration file (proguard.txt) of the app module.
So, if the library module has consumerProguardFiles 'lib-proguard-rules.txt' in its defaultConfig (see the docs), in principle, those rules will get applied automatically.
I have read in blogs and posts that the best approach is to include the .aar project without proguard and then run the proguard on aar and application project as a whole.
AFAIK, that's the typical plan. So, the AAR is left alone, with ProGuard applied on the app.
If i run proguard on Application will it affect the imported library's(already proguarded) code ?
AFAIK, the library's code should not be run through ProGuard.
I want to obfuscate my android apk file using proguard or any other method. tried many ways including :-
copy-pasting proguard.txt and proguard-optimise.txt file from sdk folder (sdk-tools-progurad) to my app module within the project directory
I have written minifyEnabled=true in gradle file of app.
After doing so facing further issue of some proguard errors giving warnings for external library class files.
Error: -Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
java.io.IOException: Please correct the above warnings first.
Even I am unable to generate signed apk.
It is strongly advised to investigate the warnings that ProGuard prints to the console and try to fix them. For this you will have to either include additional libraries or add -dontwarn directives to your proguard-project.txt file.
As a last resort, you can also use -ignorewarnings which will instruct ProGuard to continue regardless of any remaining warning.
I've set up proguard according to this link: http://android-developers.blogspot.com/2010/09/proguard-android-and-licensing-server.html
When I build with Ant I get no errors or warnings, but I also don't get any verbose output telling me that ProGuard is doing anything. By other means I'm able to tell that the apk is not being obfuscated.
All of my code, with the exception of the Activity class is in a library (as source files). I've read that the activity class will not obfuscated, but I'm wondering if I have to set up something different in my build files to include the library files?
Did you remove the debug line from your manifest?
This is a very old link.
Assuming you've downloaded the ADT plugin and the SDK this year, Proguard is bundled in the build process.
All you have to do is add this to default.properties:
proguard.config=proguard.cfg
Note that the obfuscation will occur only when you export a final version and not on every build.