android - Proguard leads to crash -


when setting

minifyenabled true

useproguard true

in gradle nullpointerexception :

java.lang.runtimeexception: unable start activity componentinfo{com.jafari.farhad.ubazdidcontroller/com.jafari.farhad.ubazdidcontroller.loginactivity}: java.lang.nullpointerexception   @ android.app.activitythread.performlaunchactivity(activitythread.java:2180)   @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230)   @ android.app.activitythread.access$600(activitythread.java:141)   @ android.app.activitythread$h.handlemessage(activitythread.java:1234)   @ android.os.handler.dispatchmessage(handler.java:99)   @ android.os.looper.loop(looper.java:137)   @ android.app.activitythread.main(activitythread.java:5041)   @ java.lang.reflect.method.invokenative(native method)   @ java.lang.reflect.method.invoke(method.java:511)   @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793)   @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560)   @ dalvik.system.nativestart.main(native method)  caused by: java.lang.nullpointerexception   @ com.jafari.farhad.ubazdidcontroller.loginactivity.oncreate(unknown source)   @ android.app.activity.performcreate(activity.java:5104)   @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080)   @ android.app.activitythread.performlaunchactivity(activitythread.java:2144)   @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230)    @ android.app.activitythread.access$600(activitythread.java:141)    @ android.app.activitythread$h.handlemessage(activitythread.java:1234)    @ android.os.handler.dispatchmessage(handler.java:99)    @ android.os.looper.loop(looper.java:137)    @ android.app.activitythread.main(activitythread.java:5041)    @ java.lang.reflect.method.invokenative(native method)    @ java.lang.reflect.method.invoke(method.java:511)    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793)    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560)    @ dalvik.system.nativestart.main(native method)  

gradle :

buildtypes {     debug {         minifyenabled false         proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'     }     release {         minifyenabled true         useproguard true         proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'     } } 

while reading through stackoverflow found settings proguard-rules.pro file this:

     -dontusemixedcaseclassnames     -dontskipnonpubliclibraryclasses     -verbose       -dontoptimize     -dontpreverify      -keepattributes *annotation*     -keep public class com.google.vending.licensing.ilicensingservice     -keep public class com.android.vending.licensing.ilicensingservice      # native methods, see http://proguard.sourceforge.net/manual/examples.html#native     -keepclasseswithmembernames class * {         native ;     }      # keep setters in views animations can still work.     # see http://proguard.sourceforge.net/manual/examples.html#beans     -keepclassmembers public class * extends android.view.view {        void set*(***);        *** get*();     }      # want keep methods in activity used in xml attribute onclick     -keepclassmembers class * extends android.app.activity {        public void *(android.view.view);     }      # enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations     -keepclassmembers enum * {         public static **[] values();         public static ** valueof(java.lang.string);     }      -keepclassmembers class * implements android.os.parcelable {       public static final android.os.parcelable$creator creator;     }      -keepclassmembers class **.r$* {         public static ;     }      -dontwarn android.support.**      # understand @keep support annotation.     -keep class android.support.annotation.keep      -keep @android.support.annotation.keep class * {*;}      -keepclasseswithmembers class * {         @android.support.annotation.keep ;     }      -keepclasseswithmembers class * {         @android.support.annotation.keep ;     }      -keepclasseswithmembers class * {         @android.support.annotation.keep (...);     } 

when disbale minifyenabled everthing works fine. thancks

you can use code in proguard

-keep class com.jafari.farhad.ubazdidcontroller.loginactivity**  

but cause proguard ignore loginactivity class, , code not obfuscation.

the best way see element has caused creation introduced proguard.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -