on click opening a dialog view it giving an out of memory? In dialog i have two images in it and 1 image button, even the size of image is 40 50kb.
04-15 10:11:07.085: E/dalvikvm-heap(29896): Out of memory on a 16384016-byte allocation.
04-15 10:11:07.085: I/dalvikvm(29896): "main" prio=5 tid=1 RUNNABLE
04-15 10:11:07.085: I/dalvikvm(29896): | group="main" sCount=0 dsCount=0 obj=0x40c51460 self=0x12938
04-15 10:11:07.085: I/dalvikvm(29896): | sysTid=29896 nice=0 sched=0/0 cgrp=default handle=1075008808
04-15 10:11:07.085: I/dalvikvm(29896): | schedstat=( 1269958584 831219251 1666 ) utm=105 stm=21 core=0
04-15 10:11:07.085: I/dalvikvm(29896): at android.graphics.Bitmap.nativeCreate(Native Method)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
04-15 10:11:07.090: I/dalvikvm(29896): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
04-15 10:11:07.090: I/dalvikvm(29896): at android.content.res.Resources.loadDrawable(Resources.java:1968)
04-15 10:11:07.090: I/dalvikvm(29896): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-15 10:11:07.095: I/dalvikvm(29896): at android.widget.ImageView.<init>(ImageView.java:119)
04-15 10:11:07.095: I/dalvikvm(29896): at android.widget.ImageView.<init>(ImageView.java:109)
04-15 10:11:07.095: I/dalvikvm(29896): at java.lang.reflect.Constructor.constructNative(Native Method)
04-15 10:11:07.095: I/dalvikvm(29896): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-15 10:11:07.095: I/dalvikvm(29896): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
04-15 10:11:07.100: I/dalvikvm(29896): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-15 10:11:07.100: I/dalvikvm(29896): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
04-15 10:11:07.100: I/dalvikvm(29896): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
Related
I am trying to add a background image to the activity by android:background=#drawable/.. as shown in the code below. But the problem is, when i add this line android:background="#drawable/introbackground" the app crashs, and when i delete it the app works normally.
To note: the image i use, i have resized it so that, it fits the entire screen. is this could be the problem?
XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/introbackground"
android:gravity="center"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.meetingpointlocator_03"
>
LOGCAT OutPut:
05-10 08:06:24.101: D/dalvikvm(17707): GC_FOR_ALLOC freed 119K, 15% free 9922K/11580K,
paused 15ms, total 15ms
05-10 08:06:24.101: I/dalvikvm-heap(17707): Forcing collection of SoftReferences for
121925780-byte allocation
05-10 08:06:24.131: D/dalvikvm(17707): GC_BEFORE_OOM freed 9K, 15% free 9912K/11580K,
paused 30ms, total 30ms
05-10 08:06:24.131: E/dalvikvm-heap(17707): Out of memory on a 121925780-byte
allocation.
05-10 08:06:24.131: I/dalvikvm(17707): "main" prio=5 tid=1 RUNNABLE
05-10 08:06:24.131: I/dalvikvm(17707): | group="main" sCount=0 dsCount=0
obj=0x41c96578 self=0x41c1ca60
05-10 08:06:24.131: I/dalvikvm(17707): | sysTid=17707 nice=-8 sched=0/0 cgrp=apps
handle=1074503676
05-10 08:06:24.131: I/dalvikvm(17707): | state=R schedstat=( 107360003 8309669 119 )
utm=6 stm=4 core=1
05-10 08:06:24.131: I/dalvikvm(17707): at
android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-10 08:06:24.131: I/dalvikvm(17707): at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
05-10 08:06:24.131: I/dalvikvm(17707): at
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
05-10 08:06:24.131: I/dalvikvm(17707): at
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
05-10 08:06:24.131: I/dalvikvm(17707): at
android.content.res.Resources.loadDrawable(Resources.java:2988)
05-10 08:06:24.131: I/dalvikvm(17707): at
android.content.res.TypedArray.getDrawable(TypedArray.java:602)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.View.<init>(View.java:3563)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.ViewGroup.<init>
(ViewGroup.java:475)
05-10 08:06:24.131: I/dalvikvm(17707): at android.widget.LinearLayout.<init>
(LinearLayout.java:176)
05-10 08:06:24.131: I/dalvikvm(17707): at android.widget.LinearLayout.<init>
(LinearLayout.java:172)
05-10 08:06:24.131: I/dalvikvm(17707): at
java.lang.reflect.Constructor.constructNative(Native Method)
05-10 08:06:24.131: I/dalvikvm(17707): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
05-10 08:06:24.131: I/dalvikvm(17707): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
05-10 08:06:24.131: I/dalvikvm(17707): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
05-10 08:06:24.131: I/dalvikvm(17707): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
05-10 08:06:24.131: I/dalvikvm(17707): at android.app.Activity.setContentView(Activity.java:1956)
05-10 08:06:24.131: I/dalvikvm(17707): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
05-10 08:06:24.131: I/dalvikvm(17707): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:111)
05-10 08:06:24.131: I/dalvikvm(17707): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
05-10 08:06:24.131: I/dalvikvm(17707): at com.example.meetingpointlocator_03.Intro.onCreate(Intro.java:38)
05-10 08:06:24.131: I/dalvikvm(17707): at android.app.Activity.performCreate(Activity.java:5372)
05-10 08:06:24.131: I/dalvikvm(17707): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
Out of memory on a 121925780-byte allocation.
You app ran out of memory.
To note: the image i use, i have resized it so that, it fits the
entire screen. is this could be the problem?
Yes the likely cause is this background image which needs to be scaled down. Each app is allocated a certain heap size. As of android 3.0 and above bitmap pixel data is stored in the heap. You need to scale down the image.
Out of Memory error with Bitmap
Also read Load a Scaled Down Version into Memory
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
You are getting OOM i.e out of memory and also the inflator exception at
android:background="#drawable/introbackground"
because the image introbackground is of very large size.
Solution
Use a .jpeg light weight image insted of using .png heavy image.
I'm getting an ANR that seems to be from Toast.makeText:
DALVIK THREADS: (mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 SUSPENDED | group="main" sCount=1 dsCount=0
obj=0x40163600 self=0x12620 | sysTid=4197 nice=0 sched=0/0
cgrp=default handle=-1345338264 | schedstat=( 149532214000 43042125000
324000 ) utm=13923 stm=1030 core=0 at
android.graphics.Matrix.native_create(Native Method) at
android.graphics.Matrix.(Matrix.java:49) at
android.view.View.(View.java:1852) at
android.view.View.(View.java:2411) at
android.view.ViewGroup.(ViewGroup.java:365) at
android.widget.LinearLayout.(LinearLayout.java:156) at
android.widget.LinearLayout.(LinearLayout.java:152) at
java.lang.reflect.Constructor.constructNative(Native Method) at
java.lang.reflect.Constructor.newInstance(Constructor.java:416) at
android.view.LayoutInflater.createView(LayoutInflater.java:576) at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.inflate(LayoutInflater.java:457) at
android.view.LayoutInflater.inflate(LayoutInflater.java:391) at
android.view.LayoutInflater.inflate(LayoutInflater.java:347) at
android.widget.Toast.makeText(Toast.java:230) at
android.widget.Toast.makeText(Toast.java:253) at
com.anthonymandra.framework.ViewerActivity.onActivityResult(ViewerActivity.java:802)
at android.app.Activity.dispatchActivityResult(Activity.java:4581) at
android.app.ActivityThread.deliverResults(ActivityThread.java:2814) at
android.app.ActivityThread.handleSendResult(ActivityThread.java:2861)
at android.app.ActivityThread.access$1000(ActivityThread.java:122) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
at android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:132) at
android.app.ActivityThread.main(ActivityThread.java:4123) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:491) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) at
dalvik.system.NativeStart.main(Native Method)
This is the line of code called from within onActivityResult:
Toast.makeText(this, R.string.save_success, Toast.LENGTH_SHORT).show();
Anyone know why a Toast might cause an ANR, or what might really be wrong if I'm misreading this? Thanks!
Instead of using direct call to R.string, you should use getResources() and then like below
String strSuccess = getString(R.string.save_success);
Toast.makeText(this, strSuccess, Toast.LENGTH_SHORT).show();
or
Toast.makeText(this, getString(R.string.save_success),Toast.LENGTH_SHORT).show();
Read more
I'm trying to add textview and progressbar's to a scrollview but it gives me a Java.Lang.IllegalStateException:
I'm using xamarin so this is not java but c# but it's the same principe
here's the code (summarized) :
SetContentView(Resource.Layout.Usage);
ScrollView scrollView = FindViewById<ScrollView>(Resource.Id.scrollView1);
LinearLayout linearLayout = FindViewById<LinearLayout>(Resource.Id.linearLayout2);
while (...){
TextView textView = new TextView(this);
textView.Text = "Some text";
textView.SetTextSize(Android.Util.ComplexUnitType.Sp, 18.0f);
linearLayout.AddView(textView);
ProgressBar progressBar = new ProgressBar(this, null, Android.Resource.Attribute.ProgressBarStyleHorizontal);
progressBar.Progress = 25;
linearLayout.AddView(progressBar);
}
scrollView.AddView(linearLayout);
Stack :
04-15 08:49:00.603 I/MonoDroid( 1389): UNHANDLED EXCEPTION: Java.Lang.IllegalStateException: Exception of type 'Java.Lang.IllegalStateException' was thrown.
04-15 08:49:00.603 I/MonoDroid( 1389): at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00023] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:368
04-15 08:49:00.603 I/MonoDroid( 1389): at Android.Views.ViewGroup.AddView (Android.Views.View) [0x0003e] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Views.ViewGroup.cs:1186
04-15 08:49:00.603 I/MonoDroid( 1389): at MyOrangeDroid.Usage.OnCreate (Android.OS.Bundle) [0x001be] in c:\Users\clement\Documents\Visual Studio 2012\Projects\MyOrangeAndroid\MyOrangeDroid\Usage.cs:70
04-15 08:49:00.603 I/MonoDroid( 1389): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.App.Activity.cs:1490
04-15 08:49:00.603 I/MonoDroid( 1389): at (wrapper dynamic-method) object.6c050c56-6d80-48bc-9425-e832938cdfa7 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
04-15 08:49:00.603 I/MonoDroid( 1389):
04-15 08:49:00.603 I/MonoDroid( 1389): --- End of managed exception stack trace ---
04-15 08:49:00.603 I/MonoDroid( 1389): java.lang.IllegalStateException: ScrollView can host only one direct child
04-15 08:49:00.603 I/MonoDroid( 1389): at android.widget.ScrollView.addView(ScrollView.java:211)
04-15 08:49:00.603 I/MonoDroid( 1389): at myorangedroid.Usage.n_onCreate(Native Method)
04-15 08:49:00.603 I/MonoDroid( 1389): at myorangedroid.Usage.onCreate(Usage.java:28)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.os.Looper.loop(Looper.java:123)
04-15 08:49:00.603 I/MonoDroid( 1389): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-15 08:49:00.603 I/MonoDroid( 1389): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 08:49:00.603 I/MonoDroid( 1389): at java.lang.reflect.Method.invoke(Method.java:507)
04-15 08:49:00.603 I/MonoDroid( 1389): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-15 08:49:00.603 I/MonoDroid( 1389): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-15 08:49:00.603 I/MonoDroid( 1389): at dalvik.system.NativeStart.main(Native Method)
In mgmain JNI_OnLoad
04-15 08:49:01.503 W/dalvikvm( 1389): JNI WARNING: JNI method called with exception raised
04-15 08:49:01.503 W/dalvikvm( 1389): in Lmyorangedroid/Usage;.n_onCreate (Landroid/os/Bundle;)V (CallObjectMethod)
04-15 08:49:01.503 W/dalvikvm( 1389): Pending exception is:
04-15 08:49:01.503 I/dalvikvm( 1389): Ljava/lang/IllegalStateException;: ScrollView can host only one direct child
04-15 08:49:01.513 I/dalvikvm( 1389): (no stack trace data found)
04-15 08:49:01.513 I/dalvikvm( 1389): "main" prio=5 tid=1 NATIVE
04-15 08:49:01.513 I/dalvikvm( 1389): | group="main" sCount=0 dsCount=0 obj=0x4001f1a8 self=0xce48
04-15 08:49:01.513 I/dalvikvm( 1389): | sysTid=1389 nice=0 sched=0/0 cgrp=default handle=-1345006528
04-15 08:49:01.513 I/dalvikvm( 1389): | schedstat=( 7098128094 1495743800 310 )
04-15 08:49:01.513 I/dalvikvm( 1389): at myorangedroid.Usage.n_onCreate(Native Method)
04-15 08:49:01.523 I/dalvikvm( 1389): at myorangedroid.Usage.onCreate(Usage.java:28)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.os.Looper.loop(Looper.java:123)
04-15 08:49:01.523 I/dalvikvm( 1389): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-15 08:49:01.523 I/dalvikvm( 1389): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 08:49:01.523 I/dalvikvm( 1389): at java.lang.reflect.Method.invoke(Method.java:507)
04-15 08:49:01.523 I/dalvikvm( 1389): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-15 08:49:01.523 I/dalvikvm( 1389): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-15 08:49:01.523 I/dalvikvm( 1389): at dalvik.system.NativeStart.main(Native Method)
04-15 08:49:01.523 I/dalvikvm( 1389):
04-15 08:49:01.523 E/dalvikvm( 1389): VM aborting
04-15 08:49:01.533 I/mono ( 1389): Stacktrace:
04-15 08:49:01.533 I/mono ( 1389):
04-15 08:49:01.533 I/mono ( 1389): at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00000] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:129
04-15 08:49:01.533 I/mono ( 1389): at Java.Lang.Throwable.get_Message () [0x0003e] in /Users/builder/data/lanes/monodroid-lion-bigsplash/0e0e51f9/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Java.Lang.Throwable.cs:195
04-15 08:49:01.533 I/mono ( 1389): at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Unhandled Exception:
Java.Lang.IllegalStateException:
Thanks for the help/read :-)
ScrollView must have only one Direct child
if you are trying to add like below
layout.AddView(textView);
layout.AddView(progressBar);
it will throw the Exception saying ScrollView must have only one direct child
Solution:
Take LinearLayout and add textView and progressbar to it and then add LinearLayout to the ScrollView
And also in your code, method names are given in Capital Letters, Remember java is Case Sensitive. I think you are just giving the above code for the overview.
Any chance you have anything inside your scrollview on your xml? If there is nothing there, try to remove all views before adding a new one. This is java but you must have an equivalent in c#.
scrollView.removeAllViews();
If you have nothing like that, remove the very first view, there will be only one anyway.
scrollView.removeView(0);
Remove all views
When getting the list of packages which is running in devices, i am getting the execption proxy stub exception from my logcat
This the code i used
List packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
This the exception which im am getting
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x40ab1478 self=0x112f910
| sysTid=1801 nice=0 sched=0/0 cgrp=default handle=1074439528
| schedstat=( 0 0 0 ) utm=465 stm=85 core=1
at android.os.BinderProxy.transact(Native Method)
at android.content.pm.IPackageManager$Stub$Proxy.getInstalledApplications(IPackageManager.java:1930)
at android.app.ApplicationPackageManager.getInstalledApplications(ApplicationPackageManager.java:414)
at com.informate.smnpd.DataUsageAppManager.processData1(DataUsageAppManager.java:237)
at com.informate.smnpd.DataUsageAppManager.processData(DataUsageAppManager.java:114)
at com.informate.smnpd.BackgroundService.getData(BackgroundService.java:667)
at com.informate.smnpd.ManualUpdate.onClick(ManualUpdate.java:221)
at android.view.View.performClick(View.java:3526)
at android.view.View$PerformClick.run(View.java:14133)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4697)
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:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
Can anyone please guide me on why this exception will occures at the time of getting installed package name. Thanks in advance
I have an application which displays a series of custom views in a LinearLayout. The LinearLayout is in a ScrollView. The custom views draw a picture, when their onDraw method is called. Generally this works fine. But occasionally the application crashes on a drawPicture() call. When it crashes, no exception seems to be thrown, but I do get this message in logcat: "Wrote stack trace to 'data/anr/traces.txt'".
The contents of traces.txt is below:
DALVIK THREADS:
"main" prio=5 tid=3 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x2aac2250 self=0x84d00
| sysTid=412 nice=0 sched=0/0 cgrp=unknown handle=2130112448
at android.graphics.Canvas.native_drawPicture(Native Method)
at android.graphics.Canvas.drawPicture(Canvas.java:1404)
at com.MyView.onDraw(PDFPageView.java:100)
at android.view.View.draw(View.java:6534)
at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
at android.view.View.draw(View.java:6537)
at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
at android.view.View.draw(View.java:6537)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
at android.view.View.draw(View.java:6537)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
at android.view.View.draw(View.java:6537)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
at android.view.View.draw(View.java:6537)
at android.widget.FrameLayout.draw(FrameLayout.java:352)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1849)
at android.view.ViewRoot.draw(ViewRoot.java:1349)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4325)
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:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
"AsyncTask #1" prio=5 tid=17 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x2e4262b0 self=0x351ab8
| sysTid=420 nice=10 sched=0/0 cgrp=unknown handle=3480528
at java.lang.Object.wait(Native Method)
- waiting on <0x195468> (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1535)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:317)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"Binder Thread #3" prio=5 tid=15 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x2e3e9cc0 self=0x191798
| sysTid=419 nice=0 sched=0/0 cgrp=unknown handle=1738736
at dalvik.system.NativeStart.run(Native Method)
"Binder Thread #2" prio=5 tid=13 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x2e3e9c00 self=0x1a7510
| sysTid=418 nice=0 sched=0/0 cgrp=unknown handle=1792360
at dalvik.system.NativeStart.run(Native Method)
"Binder Thread #1" prio=5 tid=11 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x2e3e9b40 self=0x1aae60
| sysTid=417 nice=0 sched=0/0 cgrp=unknown handle=1738512
at dalvik.system.NativeStart.run(Native Method)
"JDWP" daemon prio=5 tid=9 VMWAIT
| group="system" sCount=1 dsCount=0 s=N obj=0x2e3e82a0 self=0x1b82a0
| sysTid=416 nice=0 sched=0/0 cgrp=unknown handle=1792208
at dalvik.system.NativeStart.run(Native Method)
"Signal Catcher" daemon prio=5 tid=7 RUNNABLE
| group="system" sCount=0 dsCount=0 s=N obj=0x2e3e81e8 self=0x1b9420
| sysTid=415 nice=0 sched=0/0 cgrp=unknown handle=1791968
at dalvik.system.NativeStart.run(Native Method)
"HeapWorker" daemon prio=5 tid=5 VMWAIT
| group="system" sCount=1 dsCount=0 s=N obj=0x2d68c4c8 self=0x1b9968
| sysTid=413 nice=0 sched=0/0 cgrp=unknown handle=1792792
at dalvik.system.NativeStart.run(Native Method)
This is the logcat output:
W/WindowManager( 53): Key dispatching timed out sending to com.mypackage/com.mypackage.MyActivity
W/WindowManager( 53): Dispatch state: {{KeyEvent{action=1 code=82 repeat=0 met
a=0 scancode=229 mFlags=8} to Window{4387d7f8 Keyguard paused=false} # 129122478
0532 lw=Window{4387d7f8 Keyguard paused=false} lb=android.view.ViewRoot$W#4387d4
08 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{4392eb90 com.mypackage
s/com.mypackage.MyActivity paused=false}}}
W/WindowManager( 53): Current state: {{null to Window{4392eb90 com.mypackage
s/com.mypackage.MyActivity paused=false} # 1291225159009 lw=Window{4
392eb90 com.mypackage/com.mypackage.MyActivity paused=false} lb=an
droid.os.BinderProxy#4392e9b8 fin=false gfw=true ed=true tts=0 wf=false fp=false
mcf=Window{4392eb90
com.mypackage/com.mypackage.MyActivity paused
=false}}}
I/ActivityManager( 53): ANR in process: com.mypackage
(last in com.mypackage)
I/ActivityManager( 53): Annotation: keyDispatchingTimedOut
I/ActivityManager( 53): CPU usage:
I/ActivityManager( 53): Load: 0.71 / 0.81 / 0.44
I/ActivityManager( 53): CPU usage from 19028ms to 19ms ago:
I/ActivityManager( 53): com.mypackage: 34% = 34% user + 0% kernel / f
aults: 24 minor
I/ActivityManager( 53): system_server: 2% = 1% user + 0% kernel / faults: 8
minor
I/ActivityManager( 53): com.android.phone: 0% = 0% user + 0% kernel
I/ActivityManager( 53): adbd: 0% = 0% user + 0% kernel / faults: 72 minor
I/ActivityManager( 53): TOTAL: 38% = 36% user + 2% kernel
I/ActivityManager( 53): Removing old ANR trace file from /data/anr/traces.txt
I/Process ( 53): Sending signal. PID: 514 SIG: 3
I/dalvikvm( 514): threadid=7: reacting to signal 3
I/dalvikvm( 514): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 53 SIG: 3
I/dalvikvm( 53): threadid=7: reacting to signal 3
I/dalvikvm( 53): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 96 SIG: 3
I/dalvikvm( 96): threadid=7: reacting to signal 3
I/dalvikvm( 96): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 223 SIG: 3
I/dalvikvm( 223): threadid=7: reacting to signal 3
I/dalvikvm( 223): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 140 SIG: 3
I/dalvikvm( 140): threadid=7: reacting to signal 3
I/dalvikvm( 140): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 120 SIG: 3
I/dalvikvm( 120): threadid=7: reacting to signal 3
I/dalvikvm( 120): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 172 SIG: 3
I/dalvikvm( 172): threadid=7: reacting to signal 3
I/dalvikvm( 172): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 175 SIG: 3
I/dalvikvm( 175): threadid=7: reacting to signal 3
I/dalvikvm( 175): Wrote stack trace to '/data/anr/traces.txt'
I/Process ( 53): Sending signal. PID: 94 SIG: 3
I/dalvikvm( 94): threadid=7: reacting to signal 3
I/dalvikvm( 94): Wrote stack trace to '/data/anr/traces.txt'
W/WindowManager( 53): No window to dispatch pointer action 1
W/WindowManager( 53): No window to dispatch pointer action 1
W/WindowManager( 53): No window to dispatch pointer action 0
W/WindowManager( 53): No window to dispatch pointer action 1
D/dalvikvm( 53): GC freed 12498 objects / 629776 bytes in 174ms
This is not a crash, it's an ANR (Application Not Responding.) It means your application is taking too long to respond to an event (more than 5 seconds.)