我寫了一個應用程序,到目前爲止,我總是在sdk level 25上構建它。現在我想嘗試在較低級別上運行它,但它崩潰。雖然調試我想通了,這個鏈接給出了錯誤:在SDK 22上安裝應用程序在Bitmapfactory導致錯誤
bitmapBackgroundColors = BitmapFactory.decodeResource(this.getResources(), R.drawable.background_colors);
你有任何想法如何摧毀像一切? :D Bitmapfactory自SDK 1以來一直存在,所以這真的不能成爲問題。
我compileSdkVersion是25,我的minSdkVersion 15和我targetSdkVersion 25(雖然我仍然不明白RLY什麼這些數字的含義)
編輯:該錯誤是一個OutOfMemory錯誤。但它必須加載的.jpg只是128kb大
java.lang.OutOfMemoryError: Failed to allocate a 223948812 byte allocation with 8134272 free bytes and 180MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:467)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:497)
at com.cucumbertroup.strawberry.strawberry.GameView.<init>(GameView.java:136)
at com.cucumbertroup.strawberry.strawberry.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5389)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
編輯2:所以可能我犯了一些圖像解碼的錯誤。 我怎麼能做到這一點的效率比是:
bitmapBackgroundColors = BitmapFactory.decodeResource(this.getResources(), R.drawable.background_colors);
bitmapBackgroundColors = Bitmap.createScaledBitmap(bitmapBackgroundColors, screenX * 3, screenY, false);
什麼是logcat中顯示錯誤消息(由???)。 – Jorgesys
看看編輯 – MilamberMilamber