Attempting to call the virtual method "java.lang.Class java.lang.reflect.Field.getType ()" in a reference to a null object

I am using activeandroid in my android app.

Everything works fine, performing debug builds during development. After creating the release build of my project, the application now crashes. This happens on the Nexus5 with Android 5.0, as well as on the Nexus 7 with Android 4.4.2.

Here is the source code if you need to look! https://github.com/MetalMatze/Krautreporter

Thanks!

java.lang.RuntimeException: Unable to create application com.activeandroid.app.Application: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.reflect.Field.getType()' on a null object reference at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521) at android.app.ActivityThread.access$1500(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) 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:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.reflect.Field.getType()' on a null object reference at com.activeandroid.efc(Unknown Source) at com.activeandroid.efc(Unknown Source) at com.activeandroid.fc(Unknown Source) at com.activeandroid.f.onCreate(Unknown Source) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) at com.activeandroid.bb(Unknown Source) at com.activeandroid.ba(Unknown Source) at com.activeandroid.aa(Unknown Source) at com.activeandroid.aa(Unknown Source) at com.activeandroid.aa(Unknown Source) at com.activeandroid.app.Application.onCreate(Unknown Source) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4518) ... 9 more 
+5
source share
1 answer

You use reflection to find the field by its name. Your release build becomes a Proguard crunch that renames the fields something short and obscure. You need to add an exception to Proguard in order to preserve the names of the fields you are accessing using reflection.

There already is an answer on how to save fields in all or certain classes here: fooobar.com/questions/238990 / ...

+2
source

Source: https://habr.com/ru/post/1208756/


All Articles