gpt4 book ai didi

安卓模拟器错误

转载 作者:行者123 更新时间:2023-11-29 14:33:31 25 4
gpt4 key购买 nike

我已经成功地在一个系统中执行了一个项目,Android 2.2...

当我在其他系统中运行该项目时,使用相同的配置和模拟器选项,它崩溃了...

错误日志说:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myabc/com.myabc.Screen}: android.view.InflateException: Binary XML file line #11: Error inflating class

任何人都可以为我提供解决方案吗,因为对于要在其他系统中调试的应用程序来说这是一个严肃的解决方案...

我正在膨胀的 xml 是:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/splashback"
>
<ImageView android:id="@+id/img6" android:src="@drawable/splash71" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="0dip" android:layout_y="0dip"></ImageView>
<ImageView android:id="@+id/img5" android:src="@drawable/splash5" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="0dip" android:layout_y="0dip"></ImageView>
<ImageView android:id="@+id/img4" android:src="@drawable/splash4" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="0dip" android:layout_y="0dip"></ImageView>
<ImageView android:id="@+id/img3" android:src="@drawable/splash3" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="0dip" android:layout_y="0dip"></ImageView>
<ImageView android:id="@+id/img2" android:src="@drawable/splash2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="0dip" android:layout_y="0dip"></ImageView>
<ImageView android:id="@+id/img1" android:src="@drawable/splash1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_x="0dip" android:layout_y="0dip"></ImageView>
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/img0" android:src="@drawable/screen8" android:layout_x="0dp" android:layout_y="0dp"></ImageView>
</AbsoluteLayout>

完整的堆栈跟踪说:

04-01 10:41:57.475: E/AndroidRuntime(430): FATAL EXCEPTION: main
04-01 10:41:57.475: E/AndroidRuntime(430): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myabc/com.myabc.Screen}: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.os.Looper.loop(Looper.java:123)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-01 10:41:57.475: E/AndroidRuntime(430): at java.lang.reflect.Method.invokeNative(Native Method)
04-01 10:41:57.475: E/AndroidRuntime(430): at java.lang.reflect.Method.invoke(Method.java:521)
04-01 10:41:57.475: E/AndroidRuntime(430): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-01 10:41:57.475: E/AndroidRuntime(430): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-01 10:41:57.475: E/AndroidRuntime(430): at dalvik.system.NativeStart.main(Native Method)
04-01 10:41:57.475: E/AndroidRuntime(430): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
04-01 10:41:57.475: E/AndroidRuntime(430): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-01 10:41:57.475: E/AndroidRuntime(430): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-01 10:41:57.475: E/AndroidRuntime(430): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.Activity.setContentView(Activity.java:1647)
04-01 10:41:57.475: E/AndroidRuntime(430): at com.myabc.Screen.onCreate(Screen.java:29)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-01 10:41:57.475: E/AndroidRuntime(430): ... 11 more
04-01 10:41:57.475: E/AndroidRuntime(430): Caused by: java.lang.reflect.InvocationTargetException
04-01 10:41:57.475: E/AndroidRuntime(430): at android.widget.ImageView.<init>(ImageView.java:108)
04-01 10:41:57.475: E/AndroidRuntime(430): at java.lang.reflect.Constructor.constructNative(Native Method)
04-01 10:41:57.475: E/AndroidRuntime(430): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-01 10:41:57.475: E/AndroidRuntime(430): ... 22 more
04-01 10:41:57.475: E/AndroidRuntime(430): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.Bitmap.nativeCreate(Native Method)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.content.res.Resources.loadDrawable(Resources.java:1709)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-01 10:41:57.475: E/AndroidRuntime(430): at android.widget.ImageView.<init>(ImageView.java:118)

最佳答案

您收到 OutOfMemoryError:bitmap size exceeds VM budget。您尝试用于 ImageView 的位图似乎占用了大量内存。最好将较轻的图像文件(通过降低分辨率缩小它们)保存在您获取图像的位置。一种不太受欢迎的方法是在内存中一张一张地压缩图像并每次都 recycle()。

 private static Bitmap codec(Bitmap src, Bitmap.CompressFormat format,
int quality) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
src.compress(format, quality, os);

byte[] array = os.toByteArray();
return BitmapFactory.decodeByteArray(array, 0, array.length);
}

请参阅 http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CreateBitmap.html 中的示例

关于安卓模拟器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9962987/

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