android.os.transactiontoolargeexception in Launcher - android

We are developing enterprise applications, widgets and launcher for Android TV. We have Android set top box which runs our launcher, some widgets and apps. Widgets have fixed position in launcher when it starts.
We are getting android.os.transactiontoolargeexception in our launcher. The exception is generated randomly. Generally we have observed that when we keep box running for long time, we are facing this issue. Our box is going to run 24 * 7 at client side. So this issue is critical for us.
What is happening exactly is,
1. When we get this exception launcher crashes. We have some services which we are registering with alarm manager from our launcher's onCreate().
2. As we have only one launcher, after crashing it tries to re launch our launcher. Hence it enters into loop.
3. All our services are re registered every time in loop.
4. We do not get display for our launcher. We connect it to HDMI monitor.
We are not able to get exact cause of problem. Attaching log for the same. If anyone can suggest some solution then it will be very much appreciated.
W/ActivityManager( 3376): Force finishing activity com.sample.core.launcher/.HomeActivity
I/ActivityManager( 3376): Process com.sample.core.launcher (pid 27399) has died.
I/ActivityManager( 3376): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.sample.core.launcher/.HomeActivity u=0} from pid 0
I/ActivityManager( 3376): Start proc com.sample.core.launcher for activity com.sample.core.launcher/.HomeActivity: pid=27426 uid=1000 gids={3003, 1015, 1028, 2001, 3002, 3001}
E/AndroidRuntime(27426): FATAL EXCEPTION: main
E/AndroidRuntime(27426): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.core.launcher/com.sample.core.launcher.HomeActivity}: java.lang.RuntimeException: system server dead?
E/AndroidRuntime(27426): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
E/AndroidRuntime(27426): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
E/AndroidRuntime(27426): at android.app.ActivityThread.access$600(ActivityThread.java:130)
E/AndroidRuntime(27426): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
E/AndroidRuntime(27426): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(27426): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(27426): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime(27426): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(27426): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(27426): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime(27426): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime(27426): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(27426): Caused by: java.lang.RuntimeException: system server dead?
E/AndroidRuntime(27426): at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:133)
E/AndroidRuntime(27426): at com.sample.core.launcher.HomeActivity.onStart(HomeActivity.java:2027)
E/AndroidRuntime(27426): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1173)
E/AndroidRuntime(27426): at android.app.Activity.performStart(Activity.java:5132)
E/AndroidRuntime(27426): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
E/AndroidRuntime(27426): ... 11 more
E/AndroidRuntime(27426): Caused by: android.os.TransactionTooLargeException
E/AndroidRuntime(27426): at android.os.BinderProxy.transact(Native Method)
E/AndroidRuntime(27426): at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.startListening(IAppWidgetService.java:382)
E/AndroidRuntime(27426): at android.appwidget.AppWidgetHost.startListening(AppWidgetHost.java:130)
E/AndroidRuntime(27426): ... 15 more
W/ActivityManager( 3376): Force finishing activity com.sample.core.launcher/.HomeActivity
I/ActivityManager( 3376): Process com.sample.core.launcher (pid 27426) has died.
I/ActivityManager( 3376): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.sample.core.launcher/.HomeActivity u=0} from pid 0
Thanks

Here is a open source launcher developed for Google TV: https://github.com/entertailion/Open-Launcher-for-GTV
Maybe you could install this launcher and see if it behaves in the same way. Open Launcher does not support widgets but it has all the other home launcher features.

Related

How to debug android.view.WindowManager$BadTokenException

We're seeing quite a few of these exceptions in our crash logging tool.
The stacktrace contains only android functions:
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy#4150fa88 is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:646)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2964)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
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:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(NativeStart.java)
How would you proceed with finding the cause of this?
We can't get more information than this I'm afraid.
My guess is we're trying to show a popup or something after the activity has died.
This is usually linked to keeping references to a dead Context or starting a Dialog with the wrong Context.

android leaked window force close

I have integrated zxing barcode scanner in my app. When the scanner gets a scan it takes the result and searches an external online database via a async task then opens a new activity based on the results. I am getting a force close that is not consistent, it does not happen every scan, only sometimes so I am having trouble figuring out why I am getting a leaked window error, and only sometimes:
09-25 21:02:48.105 24371-24371/com.beerportfolio.beerportfoliopro E/WindowManager﹕ Activity com.example.beerportfoliopro.BeerPage2 has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#424b7198 that was originally added here
android.view.WindowLeaked: Activity com.example.beerportfoliopro.BeerPage2 has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#424b7198 that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:468)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:419)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:351)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:171)
at android.view.Window$LocalWindowManager.addView(Window.java:558)
at android.app.Dialog.show(Dialog.java:282)
at com.example.beerportfoliopro.GetBeerRateJSON.onPreExecute(GetBeerRateJSON.java:52)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
at android.os.AsyncTask.execute(AsyncTask.java:534)
at com.example.beerportfoliopro.GetBeerDataJSON.onPostExecute(GetBeerDataJSON.java:111)
at com.example.beerportfoliopro.GetBeerDataJSON.onPostExecute(GetBeerDataJSON.java:34)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5536)
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:1074)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:841)
at dalvik.system.NativeStart.main(Native Method)
09-25 21:02:48.265 24371-24371/com.beerportfolio.beerportfoliopro E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:784)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:476)
at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:182)
at android.app.Dialog.dismissDialog(Dialog.java:328)
at android.app.Dialog.dismiss(Dialog.java:311)
at com.example.beerportfoliopro.GetBeerRateJSON.onPostExecute(GetBeerRateJSON.java:74)
at com.example.beerportfoliopro.GetBeerRateJSON.onPostExecute(GetBeerRateJSON.java:27)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5536)
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:1074)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:841)
at dalvik.system.NativeStart.main(Native Method)
From the stack trace, it looks like your Dialog isn't visible when the AsyncTask finishes its work. In that case, the call to dismiss() will crash the app.
You might try using Dialog.isShowing() to avoid the crash:
protected void onPostExecute(...) {
...
if (dialog.isShowing()) {
dialog.dismiss(); // or .cancel()
}
...
}

Unable to start activity On Sony Experia S

I recently published my app to the android play store.
I see a whole lot of error logs from one device in particular. It's a Sony Experia S.
I contacted the owner of the device, and he says he has the latest version of android ( don't know the exact version ).
I heard from a colluege developer that there are more known issieus with sony devices and android.
This app in particular works with fragments... Don't know if this is the problem but... Maybe the sony's don't know how to cope with them.
Does anyone have an idea what this problem could be.
Error logs looks like:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.KVODeventerActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.TabControllerHome}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4511)
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:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.TabControllerHome}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:1808)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:682)
at android.widget.TabHost.setCurrentTab(TabHost.java:346)
at android.widget.TabHost.addTab(TabHost.java:236)
at com.crosscommunications.kvodeventer.KVODeventerActivity.onCreate(KVODeventerActivity.java:27)
at android.app.Activity.performCreate(Activity.java:4470)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
... 11 more
Caused by: java.lang.NullPointerException
at com.crosscommunications.kvodeventer.KVOHome.onCreateView(KVOHome.java:52)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:870)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:505)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1136)
at android.app.Activity.performStart(Activity.java:4480)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1940)
... 21 more
Thnx
Just put a null check to your code:
KVOHome Acvitivity, line 52.
at com.crosscommunications.kvodeventer.KVOHome.onCreateView(KVOHome.java:52)
Most probably, Sony sends a null value to your code.

How is Activity leak detected at run-time in Android?

From time to time, I can see logcat messages reporting activity leak. For example:
Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1#4144d6e8 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1#4144d6e8 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:763)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:567)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1081)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1068)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1062)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:341)
at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:65)
at com.android.internal.app.ResolverActivity.onCreate(ResolverActivity.java:99)
at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:53)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
at android.app.ActivityThread.access$600(ActivityThread.java:132)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4575)
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:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
My question is: how is this activity leak detected?
To detect memory leak in code, you need to install Memory Analyzer Tool plugin for eclipse.
To understand how to use MAT, please see the following link: http://android-developers.blogspot.in/2011/03/memory-analysis-for-android.html
This is a very useful plugin, though a bit difficult to understand at first go but as you will use it, you will detect the memory leak in no time.
If you face any difficulty, please ask me anytime.
Thank you :)

assetmanager has been finalized?

I'm getting that exception when I pick a wallpaper. I'm actually not sure what function is the culprit. Here's the error log:
I/ActivityManager( 1360): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
W/dalvikvm(29175): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
E/AndroidRuntime(29175): FATAL EXCEPTION: main
E/AndroidRuntime(29175): java.lang.IllegalStateException: AssetManager has been finalized!
E/AndroidRuntime(29175): at android.content.res.AssetManager.isUpToDate(Native Method)
E/AndroidRuntime(29175): at android.app.ActivityThread.getPackageInfo(ActivityThread.java:2350)
E/AndroidRuntime(29175): at android.app.ActivityThread.getPackageInfoNoCheck(ActivityThread.java:2337)
E/AndroidRuntime(29175): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2935)
E/AndroidRuntime(29175): at android.app.ActivityThread.access$3300(ActivityThread.java:125)
E/AndroidRuntime(29175): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
E/AndroidRuntime(29175): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29175): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(29175): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(29175): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(29175): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(29175): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
E/AndroidRuntime(29175): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
E/AndroidRuntime(29175): at dalvik.system.NativeStart.main(Native Method)
I/ActivityManager( 1360): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 331 ms (total 331 ms)
W/InputManagerService( 1360): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#44bf5a08
I/ActivityManager( 1360): Process com.bukabros.videolivewallpaper (pid 29175) has died.
W/ActivityManager( 1360): Scheduling restart of crashed service com.bukabros.videolivewallpaper/.VideoLiveWallpaper in 5000ms
I/ActivityManager( 1360): Start proc com.bukabros.videolivewallpaper for service com.bukabros.videolivewallpaper/.VideoLiveWallpaper: pid=29207 uid=10090 gids={}
The only thing I can think of is that onCreate doesn't get called in the right order when the wallpaper gets picked cuz that's where I instantiate the asset manager.
And yes, I'm using the NDK but the asset manager doesn't get used there.
Ah nevermind. The culprit was that the handle to the assetmanager was a static variable. (That was just a quick hack for something else). Making that a normal variable solved the problem.

Categories

Resources