重複の可能性:
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 が発生するのはなぜですか? そして、さらに重要なことは、それを避けるために何ができるでしょうか?
よろしくお願いします!