-1

问题是在将一些图像添加到资源文件夹之前,我的应用程序运行得非常好。添加后,它只是停止工作。我检查了每个图像的扩展名,但最后,我被卡住了,但出现了以下 logcat 消息。另一件事是在大型和普通设备上运行良好,但在小型设备上无法运行。提前致谢。

 10-31 11:18:25.431: E/AndroidRuntime(637): FATAL EXCEPTION: main
10-31 11:18:25.431: E/AndroidRuntime(637): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newdesign/com.example.newdesign.Recipe}: android.view.InflateException: Binary XML file line #83: Error inflating class <unknown>
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.os.Looper.loop(Looper.java:137)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.ActivityThread.main(ActivityThread.java:4424)
10-31 11:18:25.431: E/AndroidRuntime(637):  at java.lang.reflect.Method.invokeNative(Native Method)
10-31 11:18:25.431: E/AndroidRuntime(637):  at java.lang.reflect.Method.invoke(Method.java:511)
10-31 11:18:25.431: E/AndroidRuntime(637):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-31 11:18:25.431: E/AndroidRuntime(637):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-31 11:18:25.431: E/AndroidRuntime(637):  at dalvik.system.NativeStart.main(Native Method)
10-31 11:18:25.431: E/AndroidRuntime(637): Caused by: android.view.InflateException: Binary XML file line #83: Error inflating class <unknown>
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.createView(LayoutInflater.java:606)
10-31 11:18:25.431: E/AndroidRuntime(637):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-31 11:18:25.431: E/AndroidRuntime(637):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.Activity.setContentView(Activity.java:1835)
10-31 11:18:25.431: E/AndroidRuntime(637):  at com.example.newdesign.Recipe.onCreate(Recipe.java:58)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.Activity.performCreate(Activity.java:4465)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-31 11:18:25.431: E/AndroidRuntime(637):  ... 11 more
10-31 11:18:25.431: E/AndroidRuntime(637): Caused by: java.lang.reflect.InvocationTargetException
10-31 11:18:25.431: E/AndroidRuntime(637):  at java.lang.reflect.Constructor.constructNative(Native Method)
10-31 11:18:25.431: E/AndroidRuntime(637):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.LayoutInflater.createView(LayoutInflater.java:586)
10-31 11:18:25.431: E/AndroidRuntime(637):  ... 24 more
10-31 11:18:25.431: E/AndroidRuntime(637): Caused by: java.lang.OutOfMemoryError
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.content.res.Resources.loadDrawable(Resources.java:1935)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.View.<init>(View.java:2785)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.View.<init>(View.java:2722)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.view.ViewGroup.<init>(ViewGroup.java:379)
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.widget.RelativeLayout.<init>(RelativeLayout.java:174)
10-31 11:18:25.431: E/AndroidRuntime(637):  ... 27 more
4

1 回答 1

3

从这几行来看

Caused by: java.lang.OutOfMemoryError
10-31 11:18:25.431: E/AndroidRuntime(637):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

看起来你在某处有一个太大的位图(可能在资源中)

于 2012-10-31T06:24:33.043 回答