-1

I am using IBM's mobilefirst worklight version 6.3 for push notification. Everything works fine when i dont apply proguard. When i apply proguard and run the build while subscribing for the push notification only i get the following exception.

java.lang.RuntimeException: Failed to find the icon resource. Add the icon file under the /res/drawable folder.

I have the push.png named file in the drawable folder. Any suggestions on how to handle that on the proguard or is it a worklights bug?

had the same issue with another third party library but it was resolved when i added keep class com.classname.** {*;} i did the same for worklight as well -keep class com.worklight.** {*;} but it is of no use.

below is the proguard configuration that i have used

-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
-keep class com.google.gson.Gson
-keep class com.billdesk.** {*;}
-keep public class com.worklight.** {*;}
-dontwarn com.worklight.**
-dontwarn com.auth0.jwt.**
-dontwarn com.squareup.picasso.**
-dontwarn com.viewpagerindicator.**
-dontwarn org.bouncycastle.**
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Vishwajit Palankar
  • 3,033
  • 3
  • 28
  • 48

1 Answers1

2

MobileFirst 6.3 does not officially support obfuscation using Proguard. Even so, an Android project obfuscated using Proguard works fine without issues in most cases.

I am not able to recreate the issue you mention.I tested the MFP 6.3 Eventsource notifications sample after obfuscating with Proguard and the application worked fine. No runtime exceptions were seen.

Android SDK Tools : 25.1.1
Target API Level : 19
Proguard version : 4.7

To begin with:

  1. Ensure that push.png is present in all drawable folders and not just the generic one.
  2. Check the proguard obfusction logs to see if "push.png" is being crunched in all folders and look for error messages.

Modify the proguard configuration to contain-

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

-keepattributes InnerClasses
-keep class **.R
-keep class **.R$* {
    <fields>;
}

-keep class org.apache.cordova.** { *; }
-keep public class * extends org.apache.cordova.CordovaPlugin

-keep class com.worklight.androidgap.push.** { *; }
-keep class com.worklight.wlclient.push.** { *; }
-keep class com.worklight.common.security.AppAuthenticityToken { *; }

-keep class com.google.** { *;}
-dontwarn com.google.common.**
-dontwarn com.google.ads.**

-dontwarn com.worklight.androidgap.push.GCMIntentService
-dontwarn com.worklight.androidgap.plugin.WLInitializationPlugin
-dontwarn com.worklight.wlclient.push.GCMIntentService
-dontwarn org.bouncycastle.**
-dontwarn com.worklight.nativeandroid.common.WLUtils

-dontwarn com.worklight.wlclient.push.WLBroadcastReceiver
-dontwarn com.worklight.wlclient.push.common.*
-dontwarn com.worklight.wlclient.api.WLPush
Vivin K
  • 2,681
  • 1
  • 11
  • 14
  • i did the changes as mentioned by you but i am still getting the same `RunTimeException` i assume you are doing this for hybrid app i request you to please try it on the android native app as well and check . – Vishwajit Palankar Apr 25 '16 at 05:58
  • in proguard confirguration file i have added ` -keep class com.worklight.push.** { *; } -keep class com.worklight.wlclient.push.** { *; }` – Vishwajit Palankar Apr 25 '16 at 05:59
  • You were not clear on Hybrid or native in your query. So I tested on hybrid. Let me check native – Vivin K Apr 25 '16 at 07:08
  • I tested native as well. I used MobileFirst 6.3 native sample and applied Proguard-obfuscation on it. The release apk installed fine on the device, and subscription went through without issues. I have updated the answer with the Proguard configuration I used. It works for Hybrid and native. If this does not resolve your issue, then provide your sample to recreate it – Vivin K Apr 25 '16 at 09:13