Using ShowcaseView with the v7 appcompat ActionBar - android

I'm using the ShowcaseView android library to add a welcome screen when my app is first launched.
Now, on 4.0+ (and possibly 3.0, however I haven't got a device to test it) it works perfectly, however on Gingerbread, the app crashes with the following error.
09-10 15:30:31.182 1650-1650/net.rymate.notes E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: insertShowcaseViewWithType cannot be used when the theme has no ActionBar
at com.github.espiandev.showcaseview.ShowcaseView$2.run(ShowcaseView.java:231)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Is there any way to make this work on gingerbread? I want my app to be able to work on nearly all devices, which is why I'm using a lot of support APIs.
Any help is appreciated!

The short answer is "not yet". Actually working on it as I type! Check the Github issue here for more information.

Fixed in this pull request
Feel free to fork it

You can use a custom view like this: Set Custom Font in the Action Bar,
then create new ShowcaseView like:
ShowcaseView.ConfigOptions co = new ShowcaseView.ConfigOptions();
co.hideOnClickOutside = true;
ShowcaseView sv = ShowcaseView.insertShowcaseView(v, this,
"TITLE", "subtitle", co);

Related

Bad notification posted from package - Is it compulsary to hardcode values in the custom layout used for building notifications?

I am getting the following crash from Crashlytics. Not able to reproduce locally.
Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package com.abc: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.abc id=71404926 tag=null score=20 notn=Notification(pri=2 contentView=com.eterno/0x7f04016c vibrate=null sound=null defaults=0x0 flags=0x10 kind=[null]) tickerText=पीएम मोदी की पाकिस्तानी बहन राखी बांधने दिल्ली पहुंची contactCharSeq=null when=1502090973664 threadId=0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(NativeStart.java)
Since it is not happening on every device and the stack trace doesn't give much info, I have come up with the following root cause for this crash.
The notification in my app is prepared with a custom layout. The layout references a dimension as #dimen/some_value for setting the margin of the image logo.
The notification is posted to the NotificationManager via notify() function.
Meanwhile, app gets updated and #dimen/some_value gets some other resource id. (Verified this thing. Two different apks will have different resource id for the same resource).
When the system tries to draw the notification on the StatusBarNotification, it does not find the resource id and it crashes.
So, the idea is to remove the referenced variable and replace it with hardcoded string.
i.e Replace
android:layout_marginLeft="#dimen/notification_text_margin_left"
with
android:layout_marginLeft="20dp"
I did not find any official document telling me to do this, but found an answer here. Just wanted to know that can there be any other reason for this crash? Also, is the fix correct for the crash?
P.S. This crash is happening across all handsets and all OS versions.

StackOverflowError because of too deep view-hierarchy in Android

we get in the Play Store some crash reports of this kind:
java.lang.StackOverflowError
at android.graphics.Paint.getTextRunAdvances(Paint.java:1753)
at android.graphics.Paint.getTextRunAdvances(Paint.java:1726)
at android.text.TextLine.handleText(TextLine.java:758)
at android.text.TextLine.handleRun(TextLine.java:981)
at android.text.TextLine.measureRun(TextLine.java:425)
at android.text.TextLine.measure(TextLine.java:299)
at android.text.TextLine.metrics(TextLine.java:273)
.
.
.
.
at android.view.View.draw(View.java:11069)
at android.widget.FrameLayout.draw(FrameLayout.java:450)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2203)
at android.view.View.getDisplayList(View.java:10505)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:876)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:1916)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1640)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2454)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4477)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
We had such an exception on one of our test devices and it came out, that it was because of the maximum depth of the view hierarchy.
I know that the recommendation for the max depth is <10.
However, this value is quite ambitious if you have a reasonably complex app.
We use AppCompat v21 and a ViewPager on the Main-Acitivity with Fragments.
For this reason i think we have alot of "meaningless" views, which simply encapsulates one child.
Or What is the purpose of the following layouts:
-NoSaveStateFrameLayout
-NativeActionModeAwareLayout
-FitWindowsFrameLayout
Overall, we arrive a total depth of 23 including the PhoneWindowDecorView.
Our Viewtree looks like this:
Picture from Hierarchy View
The first Views from the RootView:
Picture from Hierarchy View
Nevertheless, our app works even on very old and poor Android 2.3 devices.
Why does the problem still occur in the real world.

NullPointerException at SuggestionSpan

I am getting a NullPointerException at SuggestionSpan. (Stack trace included below). As the stack trace does not include any of my code, I have absolutely no idea where to start debugging.
The error can be reproduced whenever I press space (or select a word) while using an EditText. I tried multiple keyboards including the stock Android one but the same error appears.
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.text.style.SuggestionSpan.<init>(SuggestionSpan.java:128)
at android.text.style.SuggestionSpan.<init>(SuggestionSpan.java:101)
at android.widget.SpellChecker.createMisspelledSuggestionSpan(SpellChecker.java:392)
at android.widget.SpellChecker.onGetSuggestions(SpellChecker.java:300)
at android.view.textservice.SpellCheckerSession.handleOnGetSuggestionsMultiple(SpellCheckerSession.java:198)
at android.view.textservice.SpellCheckerSession.access$000(SpellCheckerSession.java:86)
at android.view.textservice.SpellCheckerSession$1.handleMessage(SpellCheckerSession.java:112)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
EDIT: I can only reproduce the error on my Nexus S with 4.0.3, but not on emulators with other OS versions. Weird.
EDIT 2: Strange thing happened! I just dragged an EditText into another activity and the same thing happens. No code is attached to it nor any XML changes made to it.
After days of investigation, it turns out that getResources().getConfiguration().locale is null. I am not sure if it is a problem specific to some versions of Android / some devices (mine is Nexus S running 4.0.3).
But I worked around this issue by checking in the constructor of the Activity (since the context given to the SuggestionSpan is my Activity) whether the locale is null, and then set it to the default one if it is.
// to prevent a weird bug where locale is null
Configuration config = getResources().getConfiguration();
if (config.locale == null)
config.locale = Locale.getDefault();
That's what I did. I am quite sure it's not the best way though. Anyone have any more ideas?

What's causing this NullpointerException?

I've received a crash report with the following log content:
java.lang.NullPointerException
at android.webkit.PluginFullScreenHolder.show(PluginFullScreenHolder.java:85)
at android.webkit.WebView$PrivateHandler.handleMessage(WebView.java:8553)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4340)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
I have tried searching for PluginFullScreenHolder across the web, but line 85 appears to be a comment in the classes I've found.
I'm guessing the crash is related to a WebView - possibly because I'm trying to load null, but I'm very unsure of this, especially because I don't see a way for the URL to be null.
I believe the report comes from a Galaxy Nexus (on Android 4.0), if that makes any difference, but I'm not sure. If not, it's a Honeycomb device.
Anyone with experience in PluginFullScreenHolder?
Here's my code
web = (WebView) findViewById(R.id.webView1);
web.setBackgroundColor(android.R.color.black);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setPluginsEnabled(true);
web.getSettings().setUserAgent(1);
web.getSettings().setSupportZoom(false);
web.loadUrl("http://www.justin.tv/widgets/live_embed_player.swf?auto_play=true&fullscreen=true&start_volume=100&hostname=www.justin.tv&channel=" + this.getIntent().getExtras().getString("channelName"));
The weird thing is that the crash report from Market doesn't mention anything about my code - nothing what so ever - you're looking at the complete log above. It's PluginFullScreenHolder.java, no doubt.
Edit 2:
Found the correct class: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/webkit/PluginFullScreenHolder.java#PluginFullScreenHolder.show%28%29
The line in question is:
client.onShowCustomView(mLayout, mOrientation, mCallback);
Here is the PluginFullScreenHolder.java source code for android 4.0.
At line 84, you have mWebView.getWebChromeClient() which returns null according to your exception (it is used at line 85 without null check).
A workaround is to set an empty WebChromeClient (which is called when something that might impact a browser UI happens, for instance, progress updates and JavaScript alerts are sent here) :
web.setWebChromeClient(new WebChromeClient());
But this is really strange because it should never be null.
I don't know if it can bu useful and not sure about it, but it seems like the exception is related to the superclass:
android.app.Dialog
in the method show().
You might want to take a look to the source code.
Have you tried to initialize "web"?
WebView web = new WebView(this);
web = (WebView) findViewById(R.id.webView1);
if you declared your variable like this
private WebView web;
You will get the NullpointerExeption, you must initialize the object.

MapView throwing IllegalArgumentException - Wrong Image Size: 192 192

I'm getting excessive crash reports from users on a Samsung Vibrant Galaxy S. After searching around for solutions to this issue, the only thing I came across was an open issue over at Google Code: http://code.google.com/p/android/issues/detail?id=4599
The thread suggests extending MapView and catching the exceptions. Is this the best approach, or is there something better? I'd like to completely fix this issue rather than throw a bandage on it.
Here's the Stack Trace:
java.lang.IllegalArgumentException: wrong image size: 192 192
at com.google.googlenav.map.MapTile.getImage(Unknown Source)
at com.google.googlenav.map.Map.drawTile(Unknown Source)
at com.google.googlenav.map.Map.drawMapBackground(Unknown Source)
at com.google.googlenav.map.Map.drawMap(Unknown Source)
at com.google.android.maps.MapView.drawMap(MapView.java:1048)
at com.google.android.maps.MapView.onDraw(MapView.java:486)
at android.view.View.draw(View.java:6597)
at android.view.ViewGroup.drawChild(ViewGroup.java:1533)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1260)
at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1260)
at android.view.View.draw(View.java:6600)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at android.view.ViewGroup.drawChild(ViewGroup.java:1533)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1260)
at android.view.View.draw(View.java:6600)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1884)
at android.view.ViewRoot.draw(ViewRoot.java:1374)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1139)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
Hopefully someone else will show up with another answer to prove me wrong, but in my personal experience with device-specific issues, catching the exceptions often seems to be the best you can do.
Edit regarding your comment below: That is a point, and I did run into some new problems with specific devices using customised WebView code when extending WebView once.
There are a ton of people on here with far more experience than me, and I hope one of them will drop in to give a more definitive answer or less hacky solution, but if necessary, you could always use android.os.Build.DEVICE, android.os.Build.MODEL and/or android.os.Build.PRODUCT to determine whether the app is running on a Samsung Vibrant Galaxy S, and (via reflection) use the custom MapView class only if it is.
May be You have done mistake here, so change the code to correct form, or enter
<uses-library android:name="com.google.android.maps" // in manifest under inside applicaiton tag
android:required="true"/>
//wrong usage of activity
public class A extends Actvitiy
{
}
//correct usage
public class A extedns MapsActivity
{
//your all program...
}

Categories

Resources