0

I have a project which is working fine when run from eclipse, but not when installed by signed APK.

This project uses some libraries :

  1. Pulltorefresh
  2. UniversalImageLoader
  3. android support v4 (JAR)
  4. gson (JAR)
  5. youtubeandroidplayerapi (JAR)

I dont want proguard to touch any of those libraries, so i use this in proguard-project.txt :

-libraryjars libs

-keep class com.handmark.pulltorefresh.library.** { *; }
-keep interface com.handmark.pulltorefresh.library.** { *; }
-keep class com.nostra13.universalimageloader.** { *; }
-keep interface com.nostra13.universalimageloader.** { *; }

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.google.** { *; }
-keep interface com.google.** { *; }

This is my project.properties :

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

Those proguard code is working because the APK generatd after i added them has a bigger size. However, the project is still breaking when i installed it from the signed APK.

I tried to find whats going on by doing this :

retrace.bat -verbose mapping.txt dump.txt

After that, my cmd crazily output some things, but i dont know where is the error.

Please help me out, im just getting started to proguard. Thanks in advance.

EDIT Sorry guys, what i mean from "breaking" is my listview just dont showing any data/items...forever loading. No exception at all.

Blaze Tama
  • 10,828
  • 13
  • 69
  • 129

1 Answers1

2

Grouguard keep statements

Keep statements are a way to tell Proguard to keep bits of code even if they're not called from the application code directly. A good example for this is the MainActivity Activity. It is not being called from your code, but you still need to keep it in the final package and also not change its name.

Are these the only keep statements you have configured? If true, you're missing some basic ones. Here is a basic example for a minimal Android configuration (section 7): http://proguard.sourceforge.net/index.html#manual/examples.html

Retrace

Retrace is a way to recreate stack traces.

So first we need the stack trace from your crash. Run the APK on a device/emulator and get the crash exception and stacktrace. It should look like: NullPointerException at a.b.m.a(). Use the GUI retrace (it's easier to use) to get the actual stack trace, and then you can go to your original code and try and debug the crash.

Reflection and Proguard

A common reason for flows being broken by Proguard is that Proguard needs to be notified of reflection. For example - method invocation from layout XML is done via reflection, but since there is no call from your code itself, Proguard doesn't know it has the keep the relevant methods.

Please refer to this question for more info on the subject: Android, ProGuard, and keepclasseswithmembernames

If you wanna rule out reflection problems, I suggest you begin by disabling Proguard code shrinking: http://proguard.sourceforge.net/index.html#FAQ.html.

Community
  • 1
  • 1
Vaiden
  • 15,728
  • 7
  • 61
  • 91