gpt4 book ai didi

java - Android 内存不足错误

转载 作者:行者123 更新时间:2023-11-29 20:54:50 26 4
gpt4 key购买 nike

<分区>

在我的应用程序中,我有 20 多张图片是布局背景。当我添加另一张图片时,应用程序已停止工作。

01-20 22:01:51.707: E/AndroidRuntime(15045): FATAL EXCEPTION: main
01-20 22:01:51.707: E/AndroidRuntime(15045): Process: xxxxxx, PID: 15045
01-20 22:01:51.707: E/AndroidRuntime(15045): java.lang.OutOfMemoryError
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:677)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:507)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:872)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.content.res.Resources.loadDrawable(Resources.java:3056)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.content.res.Resources.getDrawable(Resources.java:1613)
01-20 22:01:51.707: E/AndroidRuntime(15045): at com.android.internal.widget.ActionBarView.setIcon(ActionBarView.java:1016)
01-20 22:01:51.707: E/AndroidRuntime(15045): at com.android.internal.policy.impl.PhoneWindow.setDefaultIcon(PhoneWindow.java:1543)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.Activity.initActionBar(Activity.java:1996)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.Activity.setContentView(Activity.java:2011)
01-20 22:01:51.707: E/AndroidRuntime(15045): at xxxxxx.onCreate(xxxxx.java:1338)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.Activity.performCreate(Activity.java:5426)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.ActivityThread.access$900(ActivityThread.java:161)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.os.Handler.dispatchMessage(Handler.java:102)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.os.Looper.loop(Looper.java:157)
01-20 22:01:51.707: E/AndroidRuntime(15045): at android.app.ActivityThread.main(ActivityThread.java:5356)
01-20 22:01:51.707: E/AndroidRuntime(15045): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 22:01:51.707: E/AndroidRuntime(15045): at java.lang.reflect.Method.invoke(Method.java:515)
01-20 22:01:51.707: E/AndroidRuntime(15045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
01-20 22:01:51.707: E/AndroidRuntime(15045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
01-20 22:01:51.707: E/AndroidRuntime(15045): at dalvik.system.NativeStart.main(Native Method)

图像在 onCreate() 方法中同时加载。

主.xml:

<LinearLayout
android:id="@+id/linearLayout27"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/abc"
android:orientation="vertical" >

onCreate():

layout26 = (LinearLayout) findViewById(R.id.linearLayout27);
layout26.setOnClickListener(this);

我应该补充一点,每张图片的大小约为 400 x 800 像素。

我知道这个问题已经出现在这里,但我找不到适合我的案例的解决方案。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com