I'm a new Proguard user and I read number of articles about it.
As I understood, the name proguard.cfg is referring to the proguard-project.txt file. Am I correct or is there such a file called proguard.cfg?
The next thing what I want to know is how could I know proguard is working well for my project? I did not add any extra comments to proguard-project.txt. I saw in some postings they said that without using the command " -dontwarn android.support.** " in proguard-project.txt will give warnings. But I did not get any warning or any exceptions in my LogCat.
Where are those warnings/exceptions displaying at? What I need to know whether it is working well.
Well, the proguard configuration is in the projects.properties file.
proguard.config=proguard-android-optimize.txt
So, whatever file you would specify here, the configurations will be picked up from that file.
I guess, the .cfg extension was being used earlier, and the documentations haven't been updated after they changed it to this file name inside android sdk tools.
Proguard is working well?
Depends on how you are building your app. Eclipse doesn't generally show all the verbose warnings, may be a few, but not all.
So, if you are building with Eclipse, you just need to assume that it worked, unless eclipse fails creating a build, and then you would see a message. To confirm, either decompile the APK, or run the app, while checking the logs. If you can crash the app, and there's a stack trace, you can clearly see the method names are obfuscated.
If you want to see all the warnings for proguard during the build process, try building your app through ant. And in the console, you can see all the details (general + proguard) warnings also.
Related
I enabled Proguard for my app and now when I get an exception, in Android Monitor I'm seeing something like
at com.mydomain.myapp.v.c(SourceFile:901)
at com.mydomain.myapp.v.a(SourceFile:1260)
In another app that I have, I also have proguard available, but I'm seeing something like
at com.mydomain.myotherapp.v.c(MainMenuScreen.java:948)
and I can click on the class name and Android Studio takes me to the exact line. I've tried copying the entire contents of the proguard file to the first app and nothing changes.
What is the setting in my project that makes Android Monitor have nice clickable links? In my proguard rules I have:
-keepattributes Exceptions, InnerClasses,
Signature, Deprecated, SourceFile, EnclosingMethod, LineNumberTable
There is a reason why you run proguard and obfuscate the code, that reason is not being able to do that! Else it would totally dismiss the point of obfuscation.
What you can do is to fetch your mapping.txt that is in your outputs folder and with the help of proguardgui.bat that is somewhere in your sdk folder you can get a normal stacktrace
I got a simple question: from several sources I learned that using Proguard to remove calls to the Andriod logging framework using the optimization steps "assumenosideeffects" is a very clean and easy way.
I wanted to get rid of all my if's in my code related to if-logging-is-on.
But then:
I learned I have to switch to proguard-android-optimize.txt settings for optimizations to work.
Already there, a warning states that Dex does not like Proguard to fiddle with the code!
It does not work. I get a Dalvik error, I guess that's exactly why it is not recommended to use Proguard's optimization features.
But then: why on earth do I encounter all these "helpful" ideas to go the Proguard way of removing log calls?
Has it been working in the past?
Can I do anything to make it work? Because I really like the idea of cleaning my code, removing all the useless String constants only used for logging, etc.
ProGuard generally works fine, but it's always possible that you've run into a bug. You should check that you are using the latest version -- ProGuard 4.10 at this time of writing. You should see the version in the console log, or by typing
java -jar android-sdk/tools/proguard/lib/proguard.jar
The Android SDK often doesn't come with the latest version, but you can manually replace the jar with a recent copy from the ProGuard site. All versions are backward compatible.
I am seeing some weird crashes on my Android application when I turn on proguard obfuscation. I understand I can debug this and skip obfuscation for those classes but my question is - Is it worth the risk of having the application crash on some phone or some code path that I might not have tested/exercised. For e.g this link talks about one such device specific error due to proguard.
I am close to release and am now wondering is it worth introducing proguard at this point. I understand I should have tested with it right from the start ..made a mistake.
Usually, the common problems with Proguard is not setting the correct parameters for third party libraries.
Make sure you've followed the instructions given by the third party providers as to the additions to the proguard.cfg file.
Anyhow, to disable proguard, you can always edit your project.properties file and remove the proguard.config=proguard.cfg line
I have been working on one project which is too complex and contain very much space with so many images and Java files as well.
Somewhere I have read about the proguard which optimizes the code.
I have used it, but it's still does not have an effect on my final APK file.
It might be I have made a mistake somewhere. I have the following this like http://developer.android.com/guide/developing/tools/proguard.html.
How can I optimize my code?
You can add it to the default.properties. I've been adding manually without having a problem so far.
If you add the line:
proguard.config=proguard.cfg
As said it will only use ProGuard when exporting signed application (Android Tools => Export Signed Application)
If you start the project with the SDK before Android 2.3 the proguard.cfg file will not be created (next to default.properties as in 2.3>).
To enable automatic creation of it, just simply update to the SDK of Android 2.3 and create a new project with existing sources (which are the sources of the project you currently have).
Automagically the proguard.cfg fill will be created.
Without optimizations the compiler produces very dumb code - each command is compiled in a very straightforward manner, so that it does the intended thing.
The Debug builds have optimizations disabled by default, because without the optimizations the produced executable matches the source code in a straightforward manner.
Please refer this one
From documentation:
ProGuard is integrated into the Android build system, so you do not have to invoke it manually. ProGuard runs only when you build your application in release mode, so you do not have to deal with obfuscated code when you build your application in debug mode.
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.