二进制XML文件行#2:错误膨胀类android.widget.LinearLayout
作者:互联网
我完全迷失了这个.我的应用程序在我的手机和模拟器上的API 2.1上完美运行.
我刚刚通过2.2模拟器运行它,我遇到了崩溃和这个错误:
04-27 20:29:41.293: ERROR/AndroidRuntime(341): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ebp/com.ebp.ebpMainMenu}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.os.Looper.loop(Looper.java:123)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at java.lang.reflect.Method.invokeNative(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at java.lang.reflect.Method.invoke(Method.java:521)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at dalvik.system.NativeStart.main(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.LinearLayout
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.Activity.setContentView(Activity.java:1622)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at com.ebp.ebpMainMenu.onCreate(ebpMainMenu.java:58)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): ... 11 more
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: java.lang.reflect.InvocationTargetException
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.widget.LinearLayout.<init>(LinearLayout.java:92)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at java.lang.reflect.Constructor.constructNative(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): ... 21 more
04-27 20:29:41.293: ERROR/AndroidRuntime(341): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.Bitmap.nativeCreate(Native Method)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.content.res.Resources.loadDrawable(Resources.java:1705)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.View.<init>(View.java:1850)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.View.<init>(View.java:1799)
04-27 20:29:41.293: ERROR/AndroidRuntime(341): at android.view.ViewGroup.<init>(ViewGroup.java:284)
在main.xml文件中,这是第2行
<LinearLayout
android:id="@+id/linearLayout3"
android:background="@drawable/mainbackground"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
这是主线58:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
解决方法:
引起:java.lang.OutOfMemoryError:位图大小超过VM预算可能是这里真正的罪魁祸首.尝试使用较小的图像来查看它是否与内存相关的问题.
查看这些链接以获取类似问题的示例:java.lang.OutOfMemoryError: bitmap size exceeds VM budget – android – how many images?
OutOfMemory exception when loading bitmap from external storage
标签:android,xml,android-inflate,android-2-2-froyo 来源: https://codeday.me/bug/20190929/1831605.html