3

Strange exception.

Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi/top_button_bg.png from drawable resource ID #0x7f020032

But this resource definitely exists. Only some users has this problem.

Help me! :(

java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.spchat.android.informer/ru.spchat.android.informerActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
 at android.app.ActivityThread.access$2300(ActivityThread.java:125)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:123)
 at android.app.ActivityThread.main(ActivityThread.java:4627)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:521)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
 at android.view.LayoutInflater.createView(LayoutInflater.java:513)
 at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
 at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
 at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
 at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
 at android.app.Activity.setContentView(Activity.java:1647)
 at ru.spchat.android.informerActivity.onCreate(informerActivity.java:110)
 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
 ... 11 more
Caused by: java.lang.reflect.InvocationTargetException
 at android.widget.LinearLayout.<init>(LinearLayout.java:115)
 at java.lang.reflect.Constructor.constructNative(Native Method)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
 at android.view.LayoutInflater.createView(LayoutInflater.java:500)
 ... 22 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi/top_button_bg.png from drawable resource ID #0x7f020032
 at android.content.res.Resources.loadDrawable(Resources.java:1714)
 at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
 at android.view.View.<init>(View.java:1897)
 at android.view.View.<init>(View.java:1846)
 at android.view.ViewGroup.<init>(ViewGroup.java:291)
 ... 26 more
Caused by: java.lang.IllegalArgumentException: width and height must be > 0
 at android.graphics.Bitmap.nativeCreate(Native Method)
 at android.graphics.Bitmap.createBitmap(Bitmap.java:481)
 at android.graphics.Bitmap.createBitmap(Bitmap.java:437)
 at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:342)
 at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:498)
 at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:472)
 at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:325)
 at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
 at android.content.res.Resources.loadDrawable(Resources.java:1709)
 ... 30 more

This resource used only in layout xml, so, this is not my code error, I think...

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/main_background_color"
    android:orientation="vertical" >

    <Button
        android:id="@+id/top_button"
        android:textColor="@color/second_text_color"
        android:textSize="16dp"
        android:textStyle="bold"
        android:background="@drawable/top_button_bg"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:layout_gravity="top"
        android:shadowColor="@color/text_shadow"
        android:shadowDx="1"
        android:shadowDy="1"
        android:shadowRadius="1"
        android:text="@string/alarmclock" />

    <ListView
        android:id="@+id/top_list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:divider="@drawable/second_background_color"
        android:dividerHeight="0.5dp"
        android:longClickable="true" />

</LinearLayout>
4

1 回答 1

0

你可以试试这个:

  1. 试着让你top_button_bg.png变小;
  2. android:background="@drawable/top_button_bg"从 xml 文件中删除,然后setBackground在 Java 中删除;
  3. 你可以检查用户手机的内存,可能内存不够大
于 2012-10-12T02:57:52.013 回答