2015-05-04 15 views
6

Mój raport awarii jest trochę bezużyteczne, jeśli używam PROGUARD (minifyEnabled true i shrinkResources true)Unknown Source kiedy używam Proguard

Jest to raport z PROGUARD:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference 
    at xx.xxxx.xxx.xxxxx.xxxxxx.restoreViewAfterLoading(Unknown Source) 
    at xx.xxxx.xxx.xxxxx.xxxxxx.newInstance(Unknown Source) 
                onCreateView 
                onViewCreated 
                access$000 
    at xx.xxxx.xxx.xxxxx.xxxxxx$1.success(Unknown Source) 
    at xx.xxxx.xxx.xxxxx.xxxxxx$1.success(Unknown Source) 
    at retrofit.CallbackRunnable$1.run(Unknown Source) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5254) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

i to jest normalne raport bez PROGUARD:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference 
    at xx.xxxx.xxx.xxxxx.xxxxxx.restoreViewAfterLoading(xxxxxx.java:123) 
    at xx.xxxx.xxx.xxxxx.xxxxxx.access$000(xxxxxx.java:26) 
    at xx.xxxx.xxx.xxxxx.xxxxxx$1.success(xxxxxx.java:96) 
    at xx.xxxx.xxx.xxxxx.xxxxxx$1.success(xxxxxx.java:92) 
    at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45) 
    at android.os.Handler.handleCallback(Handler.java:739) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5254) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

Czy jest coś, co mogę zrobić, aby uzyskać numery linii z PROGUARD?

Odpowiedz

9

Wygląda na to, że masz NPE w jakimś pliku w metodzie o nazwie restoreViewAfterLoading, gdzie setVisibility jest wywoływany na pasku postępu (który jest pusty) wokół linii 123 jakiegoś pliku. Wszystko to dzieje się w przypadku odwołania zwrotnego. Więc pierwszą rzeczą do rozwiązania jest sprawdzenie wartości NULL w przypadku, gdy użytkownik zakończy to działanie/fragment.

aby uzyskać lepszą numerację linii, należy dodać następujące do konfiguracji PROGUARD

# Preserve annotations, line numbers, and source file names 
-keepattributes *Annotation*,SourceFile,LineNumberTable 

Pozwoli to zachować numery linii w zaciemniony ślady stosu.

HTHs

+0

Czy to nie kompromis z bezpieczeństwem? – Rahul

Powiązane problemy