无法理解Android应用中的日志输出

时间:2014-12-05 18:40:36

标签: android

这是我的日志输出。我需要你帮助确定从哪里开始解决问题:

如果我在版本为4.4.2的设备中执行该应用程序,则不会抛出任何异常,但是在较低版本的设备上执行该应用程序时,应用程序崩溃..

12-05 11:34:50.716: E/AndroidRuntime(327): FATAL EXCEPTION: main
12-05 11:34:50.716: E/AndroidRuntime(327): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.solinpromex.casajuventudtrescantos/com.solinpromex.casajuventudtrescantos.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.os.Looper.loop(Looper.java:123)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.ActivityThread.main(ActivityThread.java:3683)
12-05 11:34:50.716: E/AndroidRuntime(327):  at java.lang.reflect.Method.invokeNative(Native Method)
12-05 11:34:50.716: E/AndroidRuntime(327):  at java.lang.reflect.Method.invoke(Method.java:507)
12-05 11:34:50.716: E/AndroidRuntime(327):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-05 11:34:50.716: E/AndroidRuntime(327):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-05 11:34:50.716: E/AndroidRuntime(327):  at dalvik.system.NativeStart.main(Native Method)
12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
12-05 11:34:50.716: E/AndroidRuntime(327):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
12-05 11:34:50.716: E/AndroidRuntime(327):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.Activity.setContentView(Activity.java:1657)
12-05 11:34:50.716: E/AndroidRuntime(327):  at com.solinpromex.casajuventudtrescantos.MainActivity.onCreate(MainActivity.java:28)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-05 11:34:50.716: E/AndroidRuntime(327):  ... 11 more
12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.reflect.InvocationTargetException
12-05 11:34:50.716: E/AndroidRuntime(327):  at java.lang.reflect.Constructor.constructNative(Native Method)
12-05 11:34:50.716: E/AndroidRuntime(327):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
12-05 11:34:50.716: E/AndroidRuntime(327):  ... 22 more
12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.content.res.Resources.loadDrawable(Resources.java:1709)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.widget.ImageView.<init>(ImageView.java:118)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.widget.ImageView.<init>(ImageView.java:108)
12-05 11:34:50.716: E/AndroidRuntime(327):  ... 25 more
12-05 11:34:50.726: W/ActivityManager(60):   Force finishing 

2 个答案:

答案 0 :(得分:1)

原因很清楚:

12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

解决方案:尝试使用较小分辨率的drawable。

答案 1 :(得分:1)

你的内存耗尽导致一系列问题(无法使活动xml膨胀,导致活动无法启动,因为你在未处理的onCreate方法中遇到异常)

12-05 11:34:50.716: E/AndroidRuntime(327): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.content.res.Resources.loadDrawable(Resources.java:1709)
12-05 11:34:50.716: E/AndroidRuntime(327):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)

修复它尝试在较小的设备的imageview中加载较小尺寸的位图(4.4.2之前)