解決できないAndroidプロジェクトのエラーがあります。
1つのxmlにゲームメニューレイアウトがあります:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RootView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gamemenu_background"
android:orientation="vertical" >
<Button
android:id="@+id/gaveup_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/gaveup_button">
</Button>
<Button
android:id="@+id/choice_a_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/choice_a_button">
</Button>
<Button
android:id="@+id/choice_b_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/choice_b_button"/>
</RelativeLayout>
したがって、ボタンごとに、ドローアブルフォルダにxmlと画像があります。
choice_a_button_xml.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/choice_a_button"></item>
</selector>
choice_b_button_xml.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/choice_b_button"></item>
</selector>
Eclipse de layoutのレイアウトマネージャーでは良いのですが、仮想デバイスでアプリを実行するとエラーが発生し、アプリが起動しません。
05-15 01:22:52.284: D/dalvikvm(341): GC freed 605 objects / 48664 bytes in 166ms
05-15 01:22:52.446: D/dalvikvm(341): GC freed 59 objects / 2304 bytes in 46ms
05-15 01:22:52.814: D/dalvikvm(341): GC freed 138 objects / 6344 bytes in 42ms
05-15 01:22:53.124: D/dalvikvm(341): GC freed 48 objects / 1864 bytes in 44ms
05-15 01:22:53.724: E/dalvikvm-heap(341): 3686400-byte external allocation too large for this process.
05-15 01:22:53.724: E/(341): VM won't let us allocate 3686400 bytes
05-15 01:22:53.724: D/skia(341): --- decoder->decode returned false
05-15 01:22:53.735: D/AndroidRuntime(341): Shutting down VM
05-15 01:22:53.735: W/dalvikvm(341): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
05-15 01:22:53.735: E/AndroidRuntime(341): Uncaught handler: thread main exiting due to uncaught exception
05-15 01:22:53.754: E/AndroidRuntime(341): java.lang.RuntimeException: Unable to start activity ComponentInfo{sal.app/sal.app.SALActivity}: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.os.Looper.loop(Looper.java:123)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.ActivityThread.main(ActivityThread.java:4363)
05-15 01:22:53.754: E/AndroidRuntime(341): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 01:22:53.754: E/AndroidRuntime(341): at java.lang.reflect.Method.invoke(Method.java:521)
05-15 01:22:53.754: E/AndroidRuntime(341): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-15 01:22:53.754: E/AndroidRuntime(341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-15 01:22:53.754: E/AndroidRuntime(341): at dalvik.system.NativeStart.main(Native Method)
05-15 01:22:53.754: E/AndroidRuntime(341): Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
05-15 01:22:53.754: E/AndroidRuntime(341): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-15 01:22:53.754: E/AndroidRuntime(341): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.Activity.setContentView(Activity.java:1622)
05-15 01:22:53.754: E/AndroidRuntime(341): at sal.app.SALActivity.onCreate(SALActivity.java:23)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
05-15 01:22:53.754: E/AndroidRuntime(341): ... 11 more
05-15 01:22:53.754: E/AndroidRuntime(341): Caused by: java.lang.reflect.InvocationTargetException
05-15 01:22:53.754: E/AndroidRuntime(341): at android.widget.Button.<init>(Button.java:65)
05-15 01:22:53.754: E/AndroidRuntime(341): at java.lang.reflect.Constructor.constructNative(Native Method)
05-15 01:22:53.754: E/AndroidRuntime(341): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
05-15 01:22:53.754: E/AndroidRuntime(341): ... 22 more
05-15 01:22:53.754: E/AndroidRuntime(341): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
05-15 01:22:53.754: E/AndroidRuntime(341): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:447)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.content.res.Resources.loadDrawable(Resources.java:1705)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.view.View.<init>(View.java:1850)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.widget.TextView.<init>(TextView.java:326)
05-15 01:22:53.754: E/AndroidRuntime(341): at android.widget.Button.<init>(Button.java:69)
05-15 01:22:53.754: E/AndroidRuntime(341): ... 26 more
05-15 01:22:53.774: I/dalvikvm(341): threadid=7: reacting to signal 3
05-15 01:22:53.774: E/dalvikvm(341): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
そこで何が起こりますか?このエラーは、大画面の仮想デバイスでのみ発生します。
このアプリは、仮想デバイスの最大VMアプリケーションヒープサイズを48に設定すると機能します。しかし、これは多すぎます。プログラムがより少ないメモリを消費するようにする方法はありますか?
私を助けてください