我的AVD上收到了第一个名为“我的创造力”的Android应用程序错误消息。 它显示:
不幸的是我的创造力已经停止了
它有一个简单的文本框和一个带背景的按钮。 我正在帮助google.developers,但遇到上述问题。 怎么解决这个问题?
这是我的LogCat:
02-24 10:18:48.624: I/Process(1068): Sending signal. PID: 1068 SIG: 9
02-24 10:18:51.654: W/Trace(1088): Unexpected value from nativeGetEnabledTags: 0
02-24 10:18:51.654: W/Trace(1088): Unexpected value from nativeGetEnabledTags: 0
02-24 10:18:52.194: D/dalvikvm(1088): GC_FOR_ALLOC freed 77K, 8% free 2513K/2708K, paused 52ms, total 56ms
02-24 10:18:52.534: I/dalvikvm-heap(1088): Grow heap (frag case) to 21.787MB for 20155408-byte allocation
02-24 10:18:52.674: D/dalvikvm(1088): GC_FOR_ALLOC freed 1K, 1% free 22194K/22392K, paused 137ms, total 137ms
02-24 10:18:52.784: D/dalvikvm(1088): GC_CONCURRENT freed <1K, 1% free 22194K/22392K, paused 9ms+21ms, total 109ms
02-24 10:18:55.204: D/dalvikvm(1088): GC_FOR_ALLOC freed <1K, 1% free 22194K/22392K, paused 41ms, total 41ms
02-24 10:18:55.204: I/dalvikvm-heap(1088): Forcing collection of SoftReferences for 45349648-byte allocation
02-24 10:18:55.284: D/dalvikvm(1088): GC_BEFORE_OOM freed 9K, 1% free 22184K/22392K, paused 72ms, total 73ms
02-24 10:18:55.284: E/dalvikvm-heap(1088): Out of memory on a 45349648-byte allocation.
02-24 10:18:55.284: I/dalvikvm(1088): "main" prio=5 tid=1 RUNNABLE
02-24 10:18:55.284: I/dalvikvm(1088): | group="main" sCount=0 dsCount=0 obj=0x40a719a0 self=0x2a00bba8
02-24 10:18:55.284: I/dalvikvm(1088): | sysTid=1088 nice=0 sched=0/0 cgrp=apps handle=1073849308
02-24 10:18:55.284: I/dalvikvm(1088): | state=R schedstat=( 3224239902 1154906764 146 ) utm=280 stm=42 core=0
02-24 10:18:55.284: I/dalvikvm(1088): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 10:18:55.294: I/dalvikvm(1088): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 10:18:55.294: I/dalvikvm(1088): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 10:18:55.294: I/dalvikvm(1088): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
02-24 10:18:55.294: I/dalvikvm(1088): at android.content.res.Resources.loadDrawable(Resources.java:1965)
02-24 10:18:55.304: I/dalvikvm(1088): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-24 10:18:55.304: I/dalvikvm(1088): at android.view.View.<init>(View.java:3328)
02-24 10:18:55.304: I/dalvikvm(1088): at android.view.ViewGroup.<init>(ViewGroup.java:431)
02-24 10:18:55.304: I/dalvikvm(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
02-24 10:18:55.304: I/dalvikvm(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
02-24 10:18:55.316: I/dalvikvm(1088): at java.lang.reflect.Constructor.constructNative(Native Method)
02-24 10:18:55.316: I/dalvikvm(1088): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
02-24 10:18:55.316: I/dalvikvm(1088): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-24 10:18:55.324: I/dalvikvm(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-24 10:18:55.324: I/dalvikvm(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-24 10:18:55.324: I/dalvikvm(1088): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
02-24 10:18:55.324: I/dalvikvm(1088): at android.app.Activity.setContentView(Activity.java:1881)
02-24 10:18:55.334: I/dalvikvm(1088): at com.example.iamgreat.GreatPiyu.onCreate(GreatPiyu.java:12)
02-24 10:18:55.334: I/dalvikvm(1088): at android.app.Activity.performCreate(Activity.java:5104)
02-24 10:18:55.334: I/dalvikvm(1088): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-24 10:18:55.354: I/dalvikvm(1088): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 10:18:55.354: I/dalvikvm(1088): at android.os.Looper.loop(Looper.java:137)
02-24 10:18:55.354: I/dalvikvm(1088): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-24 10:18:55.354: I/dalvikvm(1088): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 10:18:55.354: I/dalvikvm(1088): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 10:18:55.354: I/dalvikvm(1088): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-24 10:18:55.354: I/dalvikvm(1088): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-24 10:18:55.354: I/dalvikvm(1088): at dalvik.system.NativeStart.main(Native Method)
02-24 10:18:55.364: D/skia(1088): --- allocation failed for scaled bitmap
02-24 10:18:55.404: D/AndroidRuntime(1088): Shutting down VM
02-24 10:18:55.404: W/dalvikvm(1088): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
02-24 10:18:55.515: E/AndroidRuntime(1088): FATAL EXCEPTION: main
02-24 10:18:55.515: E/AndroidRuntime(1088): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iamgreat/com.example.iamgreat.GreatPiyu}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.os.Looper.loop(Looper.java:137)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-24 10:18:55.515: E/AndroidRuntime(1088): at dalvik.system.NativeStart.main(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.Activity.setContentView(Activity.java:1881)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.example.iamgreat.GreatPiyu.onCreate(GreatPiyu.java:12)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.Activity.performCreate(Activity.java:5104)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-24 10:18:55.515: E/AndroidRuntime(1088): ... 11 more
02-24 10:18:55.515: E/AndroidRuntime(1088): Caused by: java.lang.reflect.InvocationTargetException
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Constructor.constructNative(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
02-24 10:18:55.515: E/AndroidRuntime(1088): ... 23 more
02-24 10:18:55.515: E/AndroidRuntime(1088): Caused by: java.lang.OutOfMemoryError
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.content.res.Resources.loadDrawable(Resources.java:1965)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.View.<init>(View.java:3328)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.ViewGroup.<init>(ViewGroup.java:431)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
02-24 10:18:55.515: E/AndroidRuntime(1088): ... 26 more
答案 0 :(得分:5)
45349648字节分配时内存不足 我认为你正在使用大量的图像而且它无法一次性全部曝光。
看看: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html