Proguard Leads To Nullpointerexception
Solution 1:
It's likely that this happens, when serializing objects and the fields are not annotated by @SerializedName("param")
(or similar) and therefor can not be found.
For debugging it also helps to temporarily set -keepnames class **
so that the class names are not obfuscated.
Solution 2:
The idea is to keep the files provided from the libraries you included in your project. I'm sharing one of my proguard-rules.pro
which might help you to understand.
-keep classcom.google.** { *; }
-keep classcom.github.** { *; }
-keep classorg.apache.** { *; }
-keep classcom.android.** { *; }
-keep classjunit.** { *; }
-keep classandroid.support.v7.widget.SearchView { *; }
-keep classcom.myproject.model.** { *; }
Hope that helps!
Solution 3:
For me, adding lines (you may have other name for package where you put your POJO files):
-keep class [mypackagename].model.** { *; }
-keep class [mypackagename].datamodel.** { *; }
to proguard.rules
worked perfectly, then options:
android
{
...
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
}
}
are set in build.gradle
(Module: app)
Solution 4:
most of the time the error because of android libs, try this
-keep interface android.support.** { *; }-keep class android.support.** { *; }
Solution 5:
I solved the problem:
After running Clean Project
in Android Studio I got an error about a file called resource-release-stripped.ap_ that cannot be found. Some searching via Google showed up that I need to disable shrinkResources
in the gradle file because it is not compatible with Jack.
Post a Comment for "Proguard Leads To Nullpointerexception"