question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Attempt to invoke virtual method 'void android.support.v7.widget.h.a()' on a null object reference

See original GitHub issue

If 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:open
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
ben-j69commented, Feb 5, 2018

The key to solve that issue is to add : -keep class android.support.v7.widget.** { *; } It must be added in the readme

0reactions
VaibhavAWDcommented, Mar 2, 2019

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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

I am having a two null pointer Attempt to invoke virtual method ...
I am having a null pointer of, Is Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setHasFixedSize(boolean)' on ...
Read more >
Attempt to Invoke Virtual Method androidx.appcompat.app ...
Attempt to Invoke Virtual Method androidx. appcompat.app.ActionBar.hide() on a Null Object ReferenceHello Guys Welcome back, So in this video ...
Read more >
Fixed Error android error attempt to invoke virtual method
Need Help or Code Support ? Feel Free To Contact Us Here http://www.aaviskar.com/ support.phpThis video is about Fixed Error android error ...
Read more >
Getting a NullPointerException from RecyclerView ...
NullPointerException: Attempt to invoke virtual method 'boolean android.support.v7.widget.RecyclerView$ViewHolder.shouldIgnore()' on a null object reference
Read more >
[Resolved] attempt to invoke virtual method recyclerview ...
You have declared RecyclerView recyclerView; in your class, but you have not initialised it before trying to use it. So it is still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found