アクティビティ「GameActivity」で多くの画像を使用します (私は imageView.setImageDrawable(AnimationDrawable) を実行しますが、AnimationDrawable には 16 以上のフレームがあり、2 番目のアクティビティ「ShareActivity」では使用しない画像です。
それでもこのエラーが表示されます
02-13 12:36:47.943: E/AndroidRuntime(14790): FATAL EXCEPTION: main
02-13 12:36:47.943: E/AndroidRuntime(14790): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kersplatt/com.example.kersplatt.ShareActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.os.Handler.dispatchMessage(Handler.java:99)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.os.Looper.loop(Looper.java:130)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-13 12:36:47.943: E/AndroidRuntime(14790): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 12:36:47.943: E/AndroidRuntime(14790): at java.lang.reflect.Method.invoke(Method.java:507)
02-13 12:36:47.943: E/AndroidRuntime(14790): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
02-13 12:36:47.943: E/AndroidRuntime(14790): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
02-13 12:36:47.943: E/AndroidRuntime(14790): at dalvik.system.NativeStart.main(Native Method)
02-13 12:36:47.943: E/AndroidRuntime(14790): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
02-13 12:36:47.943: E/AndroidRuntime(14790): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-13 12:36:47.943: E/AndroidRuntime(14790): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.Activity.setContentView(Activity.java:1657)
02-13 12:36:47.943: E/AndroidRuntime(14790): at com.example.kersplatt.ShareActivity.onCreate(ShareActivity.java:65)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-13 12:36:47.943: E/AndroidRuntime(14790): ... 11 more
02-13 12:36:47.943: E/AndroidRuntime(14790): Caused by: java.lang.reflect.InvocationTargetException
02-13 12:36:47.943: E/AndroidRuntime(14790): at java.lang.reflect.Constructor.constructNative(Native Method)
02-13 12:36:47.943: E/AndroidRuntime(14790): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
02-13 12:36:47.943: E/AndroidRuntime(14790): ... 22 more
02-13 12:36:47.943: E/AndroidRuntime(14790): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.content.res.Resources.loadDrawable(Resources.java:1709)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.View.<init>(View.java:1951)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.View.<init>(View.java:1899)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.view.ViewGroup.<init>(ViewGroup.java:286)
02-13 12:36:47.943: E/AndroidRuntime(14790): at android.widget.LinearLayout.<init>(LinearLayout.java:120)
ここに私のすべてのXMLがあります
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="10"
android:orientation="vertical"
android:background="@drawable/fond">
<ImageView
android:id="@+id/imageView9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:scaleType="fitXY"
android:src="@drawable/bandeau" />
LINE 19 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3"
android:layout_weight="6"
android:layout_gravity="center"
android:orientation="vertical"
android:background="@drawable/fondshare" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_weight="1"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<ImageView
android:id="@+id/imageView5"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/cadre" />
<ImageView
android:id="@+id/imageView8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:layout_weight="1"
android:src="@drawable/niceshot" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:weightSum="5"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView7"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/enterthename" />
<EditText
android:id="@+id/editText1"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="4dp" />
<ImageView
android:id="@+id/imageView2"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="4dp"
android:adjustViewBounds="true"
android:src="@drawable/sharefacebook" />
<ImageView
android:id="@+id/imageView3"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="4dp"
android:adjustViewBounds="true"
android:src="@drawable/sharetwitter" />
<ImageView
android:id="@+id/imageView6"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="4dp"
android:adjustViewBounds="true"
android:src="@drawable/sharefacebook" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/imageView10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:scaleType="fitEnd"
android:src="@drawable/dim" />
</LinearLayout>
エラーはアニメーション ドローアブルが原因ですか? どうすればメモリを「クリア」したり、リサイクルしたりできますか?
編集
私の問題は
BitmapFactory.decodeFile(file.getAbsolutePath());
すでに他のビットマップをリサイクルしているので、何をクリアする必要があるかを知っておいてください