Attempt to invoke virtual method 'void android.support.v7.widget.h.a()' on a null object reference
See original GitHub issueIf the app is built with minifyEnabled true this error occur in the release build:
02-05 14:59:23.136 14849-14849/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.wayzup.wayzupapp, PID: 14849 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wayzup.wayzupapp/com.theartofdev.edmodo.cropper.CropImageActivity}: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class android.support.v7.widget.Toolbar at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6809) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class android.support.v7.widget.Toolbar Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class android.support.v7.widget.Toolbar Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at android.support.v7.app.l.v(AppCompatDelegateImplV9.java:3406) at android.support.v7.app.l.b(AppCompatDelegateImplV9.java:284) at android.support.v7.app.d.setContentView(AppCompatActivity.java:139) at com.theartofdev.edmodo.cropper.CropImageActivity.onCreate(CropImageActivity.java:58) at android.app.Activity.performCreate(Activity.java:6998) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1230) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2899) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3046) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6809) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.h.a()' on a null object reference at android.support.v7.widget.o.setBackgroundDrawable(AppCompatImageButton.java:123) at android.view.View.setBackground(View.java:20428) at android.view.View.<init>(View.java:5226) at android.widget.ImageView.<init>(ImageView.java:176) at android.widget.ImageButton.<init>(ImageButton.java:86) at android.widget.ImageButton.<init>(ImageButton.java:82) at android.support.v7.widget.o.<init>(AppCompatImageButton.java:72) at android.support.v7.widget.Toolbar.y(Toolbar.java:1361) at android.support.v7.widget.Toolbar.c(Toolbar.java:917) at android.support.v7.widget.Toolbar.<init>(Toolbar.java:321) at android.support.v7.widget.Toolbar.<init>(Toolbar.java:228)
I had this error in production, it does not occur in debug mode.
If I set minifyEnabled to false it will work
buildTypes { release { minifyEnabled false proguardFile 'proguard-android.txt' zipAlignEnabled true signingConfig signingConfigs.release } }
It looks like we need a special config for proguard no ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
The key to solve that issue is to add : -keep class android.support.v7.widget.** { *; } It must be added in the readme
Also worked for the following issue which is may be similar to the one mentioned above Thanks 🙌
2019-03-02 12:38:01.261 14748-14748/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.someapp, PID: 14748 java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.support.v7.widget.bh.a(android.content.Intent)’ on a null object reference at com.example.android.someapp.ui.DetailFragment.a(Unknown Source:46) at android.support.v4.app.d.b(Unknown Source:14) at android.support.v4.app.j.a(Unknown Source:28) at android.support.v4.app.e.onCreatePanelMenu(Unknown Source:16) at android.support.v7.view.i.onCreatePanelMenu(Unknown Source:2) at android.support.v7.app.f$c.onCreatePanelMenu(Unknown Source:8) at android.support.v7.app.f.b(Unknown Source:128) at android.support.v7.app.f.f(Unknown Source:61) at android.support.v7.app.f$2.run(Unknown Source:11) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)