可能重复:
Android:错误膨胀 xml:类未知
我的应用程序在扩展此布局时崩溃:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnSurvey"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_centerInParent="true"
android:background="@drawable/myschedulechanges_icon"
android:onClick="openSurvey" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnSurvey"
android:layout_centerHorizontal="true"
android:layout_marginTop="3dip"
android:text="Mijn\nroosterwijzigingen" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/btnAutomaticCheck"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_centerInParent="true"
android:background="@drawable/automaticcheck_icon"
android:onClick="openAutomaticCheck" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnAutomaticCheck"
android:layout_centerHorizontal="true"
android:layout_marginTop="3dip"
android:text="Automatisch\nchecken" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" >
<Button
android:id="@+id/btnManualCheck"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_centerInParent="true"
android:background="@drawable/manualcheck_icon"
android:onClick="openManualCheck" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnManualCheck"
android:layout_centerHorizontal="true"
android:layout_marginTop="3dip"
android:text="Handmatig\nchecken" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
使用这些错误消息:
11-18 09:48:15.713: E/AndroidRuntime(642): FATAL EXCEPTION: main
11-18 09:48:15.713: E/AndroidRuntime(642): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.camelotapps.augustinianum/com.camelotapps.augustinianum.ScheduleChangesActivity}: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.os.Handler.dispatchMessage(Handler.java:99)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.os.Looper.loop(Looper.java:137)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-18 09:48:15.713: E/AndroidRuntime(642): at java.lang.reflect.Method.invokeNative(Native Method)
11-18 09:48:15.713: E/AndroidRuntime(642): at java.lang.reflect.Method.invoke(Method.java:511)
11-18 09:48:15.713: E/AndroidRuntime(642): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-18 09:48:15.713: E/AndroidRuntime(642): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-18 09:48:15.713: E/AndroidRuntime(642): at dalvik.system.NativeStart.main(Native Method)
11-18 09:48:15.713: E/AndroidRuntime(642): Caused by: android.view.InflateException: Binary XML file line #46: Error inflating class <unknown>
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
11-18 09:48:15.713: E/AndroidRuntime(642): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-18 09:48:15.713: E/AndroidRuntime(642): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.Activity.setContentView(Activity.java:1835)
11-18 09:48:15.713: E/AndroidRuntime(642): at com.camelotapps.augustinianum.ScheduleChangesActivity.onCreate(ScheduleChangesActivity.java:18)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.Activity.performCreate(Activity.java:4465)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-18 09:48:15.713: E/AndroidRuntime(642): ... 11 more
11-18 09:48:15.713: E/AndroidRuntime(642): Caused by: java.lang.reflect.InvocationTargetException
11-18 09:48:15.713: E/AndroidRuntime(642): at java.lang.reflect.Constructor.constructNative(Native Method)
11-18 09:48:15.713: E/AndroidRuntime(642): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
11-18 09:48:15.713: E/AndroidRuntime(642): ... 26 more
11-18 09:48:15.713: E/AndroidRuntime(642): Caused by: java.lang.OutOfMemoryError
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.Bitmap.nativeCreate(Native Method)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.content.res.Resources.loadDrawable(Resources.java:1935)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.view.View.<init>(View.java:2785)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.widget.TextView.<init>(TextView.java:449)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.widget.Button.<init>(Button.java:108)
11-18 09:48:15.713: E/AndroidRuntime(642): at android.widget.Button.<init>(Button.java:104)
11-18 09:48:15.713: E/AndroidRuntime(642): ... 29 more
第 46 行是本节的第一行:
<Button
android:id="@+id/btnAutomaticCheck"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_centerInParent="true"
android:background="@drawable/automaticcheck_icon"
android:onClick="openAutomaticCheck" />
为什么我会收到 OutOfMemoryError?而且,更重要的是,我能做些什么来避免它?
提前谢谢了!