代码文件网址http://expirebox.com/download/63a713a00e712b22ed282da15771c3b8.html 每当我打开我的应用程序时显示此日志,(MainActivity.java:185)是setContentView(R.layout.activity_main);
12-17 11:17:35.430: E/dalvikvm-heap(23147): Out of memory on a 50331664-byte allocation.
12-17 11:17:35.430: I/dalvikvm(23147): "main" prio=5 tid=1 RUNNABLE
12-17 11:17:35.430: I/dalvikvm(23147): | group="main" sCount=0 dsCount=0 obj=0x412fb508 self=0x412eb8e8
12-17 11:17:35.430: I/dalvikvm(23147): | sysTid=23147 nice=0 sched=0/0 cgrp=apps handle=1074736944
12-17 11:17:35.430: I/dalvikvm(23147): | schedstat=( 624324163 82932674 427 ) utm=50 stm=12 core=2
12-17 11:17:35.430: I/dalvikvm(23147): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-17 11:17:35.430: I/dalvikvm(23147): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
12-17 11:17:35.430: I/dalvikvm(23147): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:476)
12-17 11:17:35.430: I/dalvikvm(23147): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
12-17 11:17:35.430: I/dalvikvm(23147): at android.content.res.Resources.loadDrawable(Resources.java:1963)
12-17 11:17:35.430: I/dalvikvm(23147): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.View.<init>(View.java:3436)
12-17 11:17:35.430: I/dalvikvm(23147): at android.widget.ImageView.<init>(ImageView.java:114)
12-17 11:17:35.430: I/dalvikvm(23147): at android.widget.ImageView.<init>(ImageView.java:110)
12-17 11:17:35.430: I/dalvikvm(23147): at java.lang.reflect.Constructor.constructNative(Native Method)
12-17 11:17:35.430: I/dalvikvm(23147): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-17 11:17:35.430: I/dalvikvm(23147): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-17 11:17:35.430: I/dalvikvm(23147): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-17 11:17:35.430: I/dalvikvm(23147): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.Activity.setContentView(Activity.java:1924)
12-17 11:17:35.430: I/dalvikvm(23147): at com.gadsdencity.activities.MainActivity.onCreate(MainActivity.java:185)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.Activity.performCreate(Activity.java:5206)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.ActivityThread.access$600(ActivityThread.java:140)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
12-17 11:17:35.430: I/dalvikvm(23147): at android.os.Handler.dispatchMessage(Handler.java:99)
12-17 11:17:35.430: I/dalvikvm(23147): at android.os.Looper.loop(Looper.java:137)
12-17 11:17:35.430: I/dalvikvm(23147): at android.app.ActivityThread.main(ActivityThread.java:4898)
12-17 11:17:35.430: I/dalvikvm(23147): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 11:17:35.430: I/dalvikvm(23147): at java.lang.reflect.Method.invoke(Method.java:511)
12-17 11:17:35.430: I/dalvikvm(23147): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
12-17 11:17:35.430: I/dalvikvm(23147): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
12-17 11:17:35.430: I/dalvikvm(23147): at dalvik.system.NativeStart.main(Native Method)
12-17 11:17:35.430: A/libc(23147): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 23147 (com.gadsdencity)
图片尺寸
答案 0 :(得分:0)
在你的activity_main布局你使用Image这个图片大小非常大,没有加载到内存中所以它崩溃和outofmemory异常。
请检查图片大小。