Using Proguard To Obfuscate Code

Hello everyone!

I’m about to launch my first big game app and have some questions for you guys who have already done so. My main question is, should I use Proguard to protect my code from people who would perhaps steal it and re-purpose it? Does this happen?

The app will be free an monetized with IAP and ads, but I would hate for someone to take the code and then make an exact duplicate (or similar duplicate) of my app. I guess that my question is - will using progaurd prevent this? What did you guys do when you launched your apps?

Any feedback is appreciated!

I use proguard in all my apps. Take a look at this: Google I/O 2011: Evading Pirates and Stopping Vampires - YouTube

Just do it. Look at it like this: It will earn you money later as there won’t be as many copycats. People might still crack it, but it deters at least some people.

May be obvious and is probably needless to say… but anyway: after obfuscating your app, don’t forget to test proguarded apk on your device thoroughly before releasing the app. That includes testing the ads, the functionality from any libraries included, etc.

We’ve been trying to implement it for 12 hours now and still having tons of issues. Mostly with errors related to Flurry analytics. My developer is about ready to give up on in! Have any of you had any problems with Flurry & Proguard?

I can’t tell for Flurry, as I am not using it. But I had issues with many libraries, and all turned out to be solvable in a way.
What errors exactly do you get?
What did you put in proguard.cfg?
Did you try:
-keep class com.flurry.** { ; }
-dontwarn com.flurry.
*

-dontwarn might resolve build, but including –dontwarn might not be safe!!

Hope someone using Flurry + Proguard will give more help.

I’m using Flurry. I used what apten wrote ( -keep class com.flurry.** { ; }
-dontwarn com.flurry.
* ) and everything has been working fine for me.

Similarly for ad networks:

Millennial Media

-keep class com.millennialmedia.android.** {*;}

-keep public class com.millennialmedia.android.*
-keepclassmembers class com.millennialmedia.android.MMAdView {
<init>(…);
public void *(…);
<methods>;
}
-keepclassmembers class com.millennialmedia.android.MMAdView$MMAdListener {
<init>(…);
public void *(…);
<methods>;
}
-keepclassmembers class com.millennialmedia.android.BasicMMAdListener {
<init>(…);
public void *(…);
<methods>;
}
-keepclassmembers class com.millennialmedia.android.MMAdViewSDK {
<init>(…);
public void *(…);
<methods>;
}

Google Ads

-keep public class com.google.ads.*
-keepclassmembers class com.google.ads.AdView {
<init>(…);
public void *(…);
}
-keepclassmembers class com.google.ads.AdSize {
public static <fields>;
}
-keepclassmembers class com.google.ads.AdRequest {
<init>(…);
public void *(…);
}
-keepclassmembers class com.google.ads.AdListener
{
<init>(…);
public void *(…);
}

Mopub Ad adapters

-keep class com.mopub.mobileads.GoogleAdMobAdapter
-keep class com.mopub.mobileads.MillennialAdapter
-keep class com.mopub.mobileads.HTML5AdView
-keep class com.mopub.mobileads.HTML5AdView {*;}

InnerActive

-keep class com.inneractive.api.ads.InneractiveAd
-keep class com.inneractive.api.ads.InneractiveAd {;}
-keep class com.inneractive.api.ads.
{*;}

InMobi

-keep class com.inmobi.** { *; }

You guys are awesome!

Yes, I am using the same for Flurry without issue.

I am using something different from the settings shown by “mind” above for Millennial Media:

cover com.google.ads.mediation.millennial

ok, is done ALREADY below for admob …

-keep public class com.google.ads.**

use without the public

#-keep public class com.millennialmedia.android.**
#-keep class com.millennialmedia.android.**

while a user suggests that this works

-keep class com.millennialmedia.android.** {*;}

do need these ?

-keep public class com.adwhirl.**

However “mind” settings may be more encompassing - as I had issues with Millennial Media full screen ads etc. (so didn’t use them). What is amazing is how Millennial Media TOTALLY IGNORES any suggestions by developers - their FAQ for the proguard settings has NOT BEEN UPDATED after numerous pointing out about that !!

How can such a company survive ? No wonder they are having problems.
It is almost as if their support staff are in bed with their competitors - to deliberately NOT put that info on proguard into their FAQs - it virtually guarantees that 50% of developers drop out from initially testing their SDK !

Settings I’m using for AppBrain:

adding 2012_09_26

need this for AppBrain Applift SDK …

as suggested by them …

-keep public class cmn.Proguard$KeepMembers
-keep public class * implements cmn.Proguard$KeepMembers
-keepclassmembers class * implements cmn.Proguard$KeepMembers {
<methods>;
}

Leadbolt:

[b]# need this for leadbolt …

as suggested by them …

-keep class com.pad.android.** { *; }

Google Admob:

need this for google admob …

as suggested on google groups etc. …

works after add this …

-keepattributes Annotation
-keep public class com.google.ads.**

Greystripe:

need this for greystripe …

without this get:

Currently fetching an ad. Cannot request another ad at this time.

works after add this …

-keep class com.greystripe.sdk.** { *; }

Flurry (same as posted by others above):

need this for flurry …

for both analytics … and flurry ads …

same .jar file for both

-keep class com.flurry.** { ; }
-dontwarn com.flurry.
*

GetJar Rewards SDK:

need this for GetJar Rewards SDK …

-keep class com.getjar.sdk.** { *; }

I think I found those parameters for MM on stackoverflow … sigh

And just in case the rest of you missed it: add the following:

-dontoptimize

NOT doing so will FUCK YOU UP… like random crashes on some devices. You have those right ? And you can never figure out why ?!? THIS IS WHY!!!

See: android - App works perfectly on 1.6, but why am I getting java.lang.VerifyError on Xperia X10 running 1.6? - Stack Overflow

very true.

Depend on your app, you can configure Proguard. This is common for all app:

proguard.config=proguard.cfg
in project.properties

And the file proguard.cfg in your root projects

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/,!class/merging/

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static ** values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

And some extra if you user external lib

-dontwarn com.google.android.youtube.**
-libraryjars /libs/AirpushSDK360.jar
-libraryjars /libs/GoogleAdMobAdsSdk-6.3.0.jar
-libraryjars /libs/YouTubeAndroidPlayerApi.jar