Search code examples
androidproguardcocos2d-jsplayscape

Crash with proguard obfuscation on Playscape SDK 1.14 on Cocos2d-JS game


We have updated to Playscape SDK 1.14 when we try to build a release APK it crashes when trying to obfuscate our libraries with proguard.

This is the proguard.cfg we used:

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-keep public class !com.pupgam.** { *; }
-dontpreverify
-dontoptimize
-verbose

-keep public class com.pupgam.ads.AdListener { *; }
-keep public class com.pupgam.ads.VideoListener { *; }
-keep public class com.pupgam.notifications.OnceService { *; }
-keep public class com.pupgam.crossyskyguriko.CrossySkyMainActivity { *; }
-keep public class com.pupgam.manager.IabManager { *; }

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
    static <methods>;
}

-keepclassmembers,allowobfuscation class * {
    @javax.inject.* *;
    @dagger.* *;
    <init>();
}

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

-keep class **$$ModuleAdapter
-keep class **$$InjectAdapter
-keep class **$$StaticInjection

-keepattributes Signature

-keepattributes *Annotation*

-keep class com.playscape.** { *; }
-keep class com.mominis.** { *; }
-keep class mobpartner.** { *; }
-keep class mominis.** { *; }
-keep class com.android.** { *; }
-keep class com.android.volley.* {*;}
-keep class com.google.vending.* {*;}
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class com.amazon.** { *; }
-keep class com.startapp.** { *; }
-keep class com.millennialmedia.** { *; }
-keep class com.chartboost.** { *; }
-keep class com.jirbo.** { *; }
-keep class com.google.** { *; }
-keep class com.facebook.** { *; }
-keep class com.vungle.** { *; }

-dontnote android.support.**
-dontnote com.adience.sdk.SdkBootReceiver
-dontnote com.adience.sdk.av
-dontnote com.google.android.gms.maps.internal.u
-dontnote com.google.gson.internal.UnsafeAllocator
-dontnote com.millennialmedia.google.gson.internal.UnsafeAllocator
-dontnote com.startapp.android.publish.gson.internal.UnsafeAllocator
-dontnote com.vungle.publisher.cm

-dontnote com.google.vending.licensing.ILicensingService
-dontnote com.android.vending.licensing.ILicensingService
-dontnote com.millennialmedia.android.VideoPlayer
-dontnote com.mopub.mobileads.MoPubActivity
-dontnote com.mopub.mobileads.MraidActivity
-dontnote com.mopub.mobileads.MraidBrowser
-dontnote com.mopub.mobileads.MraidVideoPlayerActivity
-dontnote com.playscape.utils.gcm.GCMBroadcastReceiver
-dontnote com.playscape.utils.kernel.NotificationActionListener
-dontnote com.vungle.sdk.VungleIntentService
-dontnote mominis.gameconsole.activities.RedirectToMarketActivity
-dontnote mominis.gameconsole.services.impl.SocialService

-keep class com.google.vending.licensing.ILicensingService
-keep class com.android.vending.licensing.ILicensingService
-keep class com.millennialmedia.android.VideoPlayer
-keep class com.mopub.mobileads.MoPubActivity
-keep class com.mopub.mobileads.MraidActivity
-keep class com.mopub.mobileads.MraidBrowser
-keep class com.mopub.mobileads.MraidVideoPlayerActivity
-keep class com.playscape.utils.gcm.GCMBroadcastReceiver
-keep class com.playscape.utils.kernel.NotificationActionListener
-keep class com.vungle.sdk.VungleIntentService
-keep class mominis.gameconsole.activities.RedirectToMarketActivity
-keep class mominis.gameconsole.services.impl.SocialService

-dontwarn com.millennialmedia.android.**

-dontwarn com.facebook.**
-dontwarn com.amazon.**
-dontwarn com.adience.sdk.e.y
-dontwarn com.playscape.gcm.services.impl.ClientSettings
-dontwarn com.playscape.utils.StrictModeDisabler

-dontwarn com.playscape.iap_utils.IPurchaseEventHandler$IPurchaseEventListener
-dontwarn mominis.common.MoDiMapper
-dontwarn com.playscape.lifecycle.ActivityLifeCycle
-dontwarn com.playscape.iap_utils.IPurchaseEventHandler
-dontwarn com.playscape.iap.AndroidRemoteLoggerAspect
-dontwarn com.playscape.lifecycle.ActivityAspect
-dontwarn com.playscape.playscapeapp.AutomatedEventLoger
-dontwarn com.playscape.playscapeapp.PlayscapeStartup
-dontwarn com.playscape.publishingkit.Playscape
-dontwarn com.playscape.publishingkit.PlayscapeActivityLifeCycle
-dontwarn com.playscape.publishingkit.PlayscapeDemoActivity
-dontwarn com.playscape.lifecycle.AppAspect
-dontwarn com.playscape.playscapeapp.AutomatedEventLoger$1
-dontwarn com.playscape.playscapeapp.PlayscapeStartup$AppMapper
-dontwarn com.playscape.playscapeapp.PlayscapeStartup$AppMapper

-dontnote com.playscape.playscapeapp.PlayscapeStartup
-dontnote com.playscape.publishingkit.Playscape

-keep class com.amatellanes.android.MainActivity
-dontwarn com.vungle.publisher.location.GoogleLocationClientDetailedLocationProvider
-dontnote com.google.gson.internal.$Gson$Types$ParameterizedTypeImpl
-dontnote com.millennialmedia.google.gson.internal.$Gson$Types$ParameterizedTypeImpl
-dontnote com.startapp.android.publish.gson.internal.$Gson$Types$ParameterizedTypeImpl
-dontnote org.aspectj.internal.lang.reflect.AjTypeImpl
-dontnote org.aspectj.internal.lang.reflect.StringToType$1
-dontnote com.google.android.gms.maps.internal.x

We used the default proguard-project.txt and merge with our current configuration where we want to obfuscate all classes except:

-keep public class com.pupgam.ads.AdListener { *; }
-keep public class com.pupgam.ads.VideoListener { *; }
-keep public class com.pupgam.notifications.OnceService { *; }
-keep public class com.pupgam.crossyskyguriko.CrossySkyMainActivity { *; }
-keep public class com.pupgam.manager.IabManager { *; }

The exception reported when executing proguard based on custom_rules.xml:

BUILD FAILED
/Users/it4up/Desktop/CrossySky/frameworks/runtime-src/proj.android/custom_rules.xml:556: The following error occurred while executing this line:
/Users/it4up/Desktop/CrossySky/frameworks/runtime-src/proj.android/custom_rules.xml:558: The following error occurred while executing this line:
/Users/it4up/Desktop/CrossySky/frameworks/runtime-src/proj.android/custom_rules.xml:570: The following error occurred while executing this line:
/Users/it4up/Desktop/CrossySky/frameworks/runtime-src/proj.android/custom_rules.xml:538: The following error occurred while executing this line:
/Users/it4up/Desktop/CrossySky/frameworks/runtime-src/proj.android/custom_rules.xml:497: Please correct the above warnings first.

Solution

  • Your proguard configs file should contain these flags:

    • -keepattributes Signature;
    • -dontwarn. Specifies not to warn about unresolved references and other important problems at all;
    • -dontnote. Specifies not to print notes about potential mistakes or omissions in the configuration.

    Also just add -keep class for your classes you want to keep without obfuscation. You can familiarize here