New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"java.lang.IllegalArgumentException: Given null view to target" when calling TapTarget.forToolbarMenuItem #168
Comments
+1 |
I think I figured this one out. The sample app is inflating the toolbar with the menu.
I was using setSupportActionBar(toolbar) and then inflating the menu in onCreateOptionsMenu
So when you're calling
The toolbar doesn't actually have any menu items and throws the error. I'm not sure if inflating the menu in the toolbar, and then calling setSupportActionBar(toolbar) will cause unknown problems though? This should really be clarified in the documentation if there's no problem inflating the toolbar in addition to the setSupportActionBar(toolbar) OR make it work with the support method. |
Thanks for your help @babramovitch, unfortunately |
@tijee Weird, it does call This was on a LG G4 running 6.0.1 and a Moto G running 4.4 |
Yeah I'm not sure maybe I need to look further, for now what I'm doing is creating my menu as usual in |
Any solution about this issue? I get:
|
@fgagneten The method I described above is still working for me and I haven't encountered any problems so far, although to be cautious, I only load the menu into the toolbar if I'm going to show a tap target. Specifically - set the toolbar xml in addition to initializing the support action bar with the toolbar I'd give it a shot. I think that's the best you're going to get pending the library being updated to work with the support actionbar initialized with a toolbar. |
@fgagneten check this out #168 (comment) |
Change:
With the following line:
|
@fgagneten working good. No more reported FC in Crashlitics. Thank you. |
This is interesting. Is there a sample project that reproduces this issue? |
@xiphirx I can put one together quickly later. It's just taking the sample app and removing line 31, and also configuring the the toolbar via setSupportActionBar |
So the issue here is that by setting up the In my testing, What you can do, though, is listen for the next immediate layout of the
This isn't something that the library can feasibly do well for you, so I'd advise moving away from "setSupportActionBar" entirely and just using the |
This is my solution: Firtly we must follow the activity lifecycle, so to configure the tap targets I used the
Then we must to wait the
And now we must to
|
I am trying to do the same but for a menu item inside the overflow menu.
Trying to target this menu item always returns the
I am starting to think this has something to do with the fact that Has the library consider this usecase? |
I have just use a mHandler.postDelay(runnable, 500) to display tap target. at this time all views was created and ItemMenu inflatted. |
this code with my problem solved. Thanks |
i use this :
|
Version used:
Latest: 1.9.1
Stack trace:
Fatal Exception: java.lang.IllegalArgumentException: Given null view to target
at com.getkeepsafe.taptargetview.ViewTapTarget.(ViewTapTarget.java:31)
at com.getkeepsafe.taptargetview.ToolbarTapTarget.(ToolbarTapTarget.java:36)
at com.getkeepsafe.taptargetview.TapTarget.forToolbarMenuItem(TapTarget.java:151)
at sk.henrichg.phoneprofilesplus.EditorProfilesActivity.showTargetHelps(EditorProfilesActivity.java:1956)
at sk.henrichg.phoneprofilesplus.EditorProfilesActivity.access$500(EditorProfilesActivity.java:67)
at sk.henrichg.phoneprofilesplus.EditorProfilesActivity$6.run(EditorProfilesActivity.java:513)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at dalvik.system.NativeStart.main(NativeStart.java)
Android version:
Reported FC - API level <= 19
My application uses android.support.v7.widget.Toolbar, support lib version: 25.3.1, toolbar is act as the ActionBar via setSupportActionBar().
The text was updated successfully, but these errors were encountered: