0

An external collections library that I'm using allows me to execute a where method on a list of custom objects. It needs the method/property name that I want to filter on and it takes it as a string. Because of obfuscation being done, the method doesn't seem to exist.

I'm trying to tell proguard not to obfuscate methods on that object but it's not working.

In proguard config, I'm trying this

-keep public class com.mop.mobile.myproject.obj.MyClass**
-keepnames public class com.mop.mobile.myproject.obj.MyClass**

here's the logcat trace

E/AndroidRuntime(20419): FATAL EXCEPTION: main
E/AndroidRuntime(20419): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{com.mop.mobile.myproject/com.mop.mobile.myproject.MyPagerActivity}: java.la
ng.RuntimeException: java.lang.RuntimeException: java.lang.NoSuchMethodException
: getMyId []
E/AndroidRuntime(20419):        at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2059)
E/AndroidRuntime(20419):        at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2084)
E/AndroidRuntime(20419):        at android.app.ActivityThread.access$600(Activit
yThread.java:130)
E/AndroidRuntime(20419):        at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1195)
E/AndroidRuntime(20419):        at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime(20419):        at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(20419):        at android.app.ActivityThread.main(ActivityThrea
d.java:4745)
E/AndroidRuntime(20419):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(20419):        at java.lang.reflect.Method.invoke(Method.java:5
11)
E/AndroidRuntime(20419):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime(20419):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:553)
E/AndroidRuntime(20419):        at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime(20419): Caused by: java.lang.RuntimeException: java.lang.Runtim
eException: java.lang.NoSuchMethodException: getMyId []
E/AndroidRuntime(20419):        at com.a.a.b.a.a.a(Unknown Source)
E/AndroidRuntime(20419):        at com.a.a.b.a.b.a(Unknown Source)
E/AndroidRuntime(20419):        at com.a.a.b.a.a(Unknown Source)
E/AndroidRuntime(20419):        at com.mop.mobile.myproject.MyPagerActivity.a(Unknow
n Source)
E/AndroidRuntime(20419):        at com.mop.mobile.myproject.MyPagerActivity.onCreate
(Unknown Source)
E/AndroidRuntime(20419):        at android.app.Activity.performCreate(Activity.j
ava:5008)
E/AndroidRuntime(20419):        at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1079)
E/AndroidRuntime(20419):        at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2023)
E/AndroidRuntime(20419):        ... 11 more
E/AndroidRuntime(20419): Caused by: java.lang.RuntimeException: java.lang.NoSuch
MethodException: getMyId []
E/AndroidRuntime(20419):        at com.a.a.c.a.a(Unknown Source)
E/AndroidRuntime(20419):        ... 19 more
E/AndroidRuntime(20419): Caused by: java.lang.NoSuchMethodException: getOverallP
riorityId []
E/AndroidRuntime(20419):        at java.lang.Class.getConstructorOrMethod(Class.
java:460)
E/AndroidRuntime(20419):        at java.lang.Class.getMethod(Class.java:915)
E/AndroidRuntime(20419):        ... 20 more
W/ActivityManager(  307):   Force finishing activity com.mop.mobile.myproject/.Asse
tListPager
W/ActivityManager(  307):   Force finishing activity com.mop.mobile.myproject/.Near
MeActivity
W/ActivityManager(  307): Activity pause timeout for ActivityRecord{435fbdc0 com
.mop.mobile.myproject/.MyPagerActivity}
I/ActivityManager(  307): No longer want com.google.android.gms (pid 20052): hid
den #16
W/System.err(20419): IOException processing: 26
W/System.err(20419): java.io.IOException: Server returned: 3
W/System.err(20419):    at android_maps_conflict_avoidance.com.google.googlenav.
map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
W/System.err(20419):    at android_maps_conflict_avoidance.com.google.googlenav.
map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
W/System.err(20419):    at android_maps_conflict_avoidance.com.google.googlenav.
datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:
1117)
W/System.err(20419):    at android_maps_conflict_avoidance.com.google.googlenav.
datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994
)
W/System.err(20419):    at android_maps_conflict_avoidance.com.google.googlenav.
datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.jav
a:1702)
W/System.err(20419):    at java.lang.Thread.run(Thread.java:856)
W/ActivityManager(  307): Activity destroy timeout for ActivityRecord{42a743d0 c
om.mop.mobile.myproject/.myprojectActivity}
W/ActivityManager(  307): Activity destroy timeout for ActivityRecord{435fbdc0 c
om.mop.mobile.myproject/.MyPagerActivity}
topwik
  • 3,487
  • 8
  • 41
  • 65
  • just as a reference, this also seemed to work as well http://stackoverflow.com/questions/7880107/in-proguard-how-to-preserve-a-set-of-classes-method-names – topwik Oct 09 '12 at 20:59

2 Answers2

3

Try this:

-keep public class com.mop.mobile.myproject.obj.MyClass { *; }

instead of

-keep public class com.mop.mobile.myproject.obj.MyClass**
t0mm13b
  • 34,087
  • 8
  • 78
  • 110
2

To tell proguard not to obfuscate methods/attributes of a certain class use these lines...

keepclassmembers class com.mop.mobile.myproject.obj.MyClass{*;}

keepattributes com.mop.mobile.myproject.obj.MyClass

It worked for me .

Neha Shukla
  • 3,572
  • 5
  • 38
  • 69