2

アクティビティの 1 つで、さまざまな向きに合わせてさまざまな xml レイアウトを統合しました。Android 4.0 では、向きを変更しても問題ありませんが、1.6 ではクラッシュします。なんで?解決策はありますか?

これが私の丸太猫です:

        10-06 17:49:07.539: I/ActivityManager(51): Displayed activity com.xyz.android.test/.MainActivity: 4038 ms (total 4038 ms)
        10-06 17:49:17.139: I/WindowManager(51): onOrientationChanged, rotation changed to 1
        10-06 17:49:17.139: I/WindowManager(51): Setting rotation to 1, animFlags=0
        10-06 17:49:17.169: I/WindowManager(51): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=1/1/2 nav=3 orien=2 layout=34}
        10-06 17:49:17.269: D/StatusBar(51): updateResources
        10-06 17:49:17.569: D/dalvikvm(255): GC freed 177 objects / 10496 bytes in 45ms
        10-06 17:49:18.009: D/dalvikvm(255): GC freed 65 objects / 2600 bytes in 42ms
        10-06 17:49:18.369: E/dalvikvm-heap(255): 589824-byte external allocation too large for this process.
        10-06 17:49:18.369: E/(255): VM won't let us allocate 589824 bytes
        10-06 17:49:18.369: D/AndroidRuntime(255): Shutting down VM
        10-06 17:49:18.379: W/dalvikvm(255): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
        10-06 17:49:18.379: E/AndroidRuntime(255): Uncaught handler: thread main exiting due to uncaught exception
        10-06 17:49:18.389: E/AndroidRuntime(255): android.view.InflateException: Binary XML file line #40: Error inflating class java.lang.reflect.Constructor
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.createView(LayoutInflater.java:512)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:620)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.app.Activity.setContentView(Activity.java:1620)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at com.xyz.android.test.MainActivity.onConfigurationChanged(MainActivity.java:55)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:3607)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:3673)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1864)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.os.Handler.dispatchMessage(Handler.java:99)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.os.Looper.loop(Looper.java:123)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.app.ActivityThread.main(ActivityThread.java:4203)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at java.lang.reflect.Method.invokeNative(Native Method)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at java.lang.reflect.Method.invoke(Method.java:521)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at dalvik.system.NativeStart.main(Native Method)
        10-06 17:49:18.389: E/AndroidRuntime(255): Caused by: java.lang.reflect.InvocationTargetException
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.widget.ImageView.<init>(ImageView.java:105)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at java.lang.reflect.Constructor.constructNative(Native Method)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.view.LayoutInflater.createView(LayoutInflater.java:499)
        10-06 17:49:18.389: E/AndroidRuntime(255):  ... 21 more
        10-06 17:49:18.389: E/AndroidRuntime(255): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.Bitmap.nativeCreate(Native Method)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:476)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:322)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:688)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.content.res.Resources.loadDrawable(Resources.java:1710)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.content.res.Resources.getDrawable(Resources.java:585)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:146)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:779)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.graphics.drawable.Drawable.createFromXml(Drawable.java:720)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.content.res.Resources.loadDrawable(Resources.java:1695)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
        10-06 17:49:18.389: E/AndroidRuntime(255):  at android.widget.ImageView.<init>(ImageView.java:115)
        10-06 17:49:18.389: E/AndroidRuntime(255):  ... 25 more
        10-06 17:49:18.409: I/Process(51): Sending signal. PID: 255 SIG: 3
        10-06 17:49:18.419: I/dalvikvm(255): threadid=7: reacting to signal 3
        10-06 17:49:18.419: E/dalvikvm(255): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
        10-06 17:49:19.139: W/WindowManager(51): Window freeze timeout expired.
        10-06 17:49:19.139: W/WindowManager(51): Force clearing orientation change: Window{43970380 com.xyz.android.test/com.xyz.android.test.MainActivity paused=false}
        10-06 17:49:21.219: D/dalvikvm(51): GC freed 1812 objects / 89840 bytes in 79ms
        10-06 17:49:22.279: W/SurfaceFlinger(51): timeout expired mFreezeDisplay=0, mFreezeCount=1
4

2 に答える 2

3

重要な行は次のとおりです。

Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

あなたが持っているよりも多くのメモリを必要とするビットマップがあると言っています。
エミュレーターでテストした場合、十分なメモリを使用できなかった可能性があります。
そうしないと、画像が大きすぎるため、その品質を再利用する必要があります。

于 2012-10-06T16:51:03.607 に答える
0

1.6 の xml レイアウトに問題があるようです:

android.view.InflateException: Binary XML file line #40: 

40行目

于 2012-10-06T16:42:43.637 に答える