正在进行的通知RemoteServiceException - 无法扩展RemoteViews:StatusBarNotification

时间:2017-09-06 16:38:15

标签: android

我已经点击了我在此问题上找到的每个SO链接,但似乎都没有合适。

这里有完整的错误:

Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package my.package.name: Couldn't expand RemoteViews for: StatusBarNotification(pkg=my.package.name user=UserHandle{0} id=328 tag=null key=0|my.package.name|328|null|10243: Notification(pri=2 contentView=my.package.name/0x7f040049 vibrate=null sound=null defaults=0x0 flags=0x22 color=0x00000000 vis=PUBLIC semFlags=0x0 semPriority=0))
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1813)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6776)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

在我的搜索中,我已经了解到ID引用可以在应用升级时发生变化,但此错误似乎并未指向可绘制资源或类似内容,看起来问题出现在布局文件,但我不确定那里有什么问题。

这里是由 contentView = [my.package.name] / 0x7f040049 定义的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="65dp"
    android:background="@color/black"
    android:paddingBottom="8dp"
    android:paddingLeft="6dp"
    android:paddingRight="6dp"
    android:paddingTop="8dp">

    <ImageView
        android:id="@+id/notification_weather_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:adjustViewBounds="true"
        android:src="@drawable/notification_icon" />

    <TextView
        android:id="@+id/notification_weather_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginStart="5dp"
        android:layout_marginEnd="5dp"
        android:layout_toEndOf="@id/notification_weather_icon"
        android:layout_toRightOf="@id/notification_weather_icon"
        android:fontFamily="@string/roboto_thin"
        android:gravity="center"
        android:textColor="@color/white"
        android:textSize="35sp"
        tools:text="40*" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_toEndOf="@+id/notification_weather_text"
        android:layout_toRightOf="@+id/notification_weather_text"
        android:gravity="center_vertical"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/weather_type_layout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginTop="2.5dp"
            android:layout_weight="1"
            android:gravity="bottom">

            <TextView
                android:id="@+id/notification_weather_type"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:ellipsize="end"
                android:fontFamily="@string/roboto_light"
                android:gravity="start|bottom"
                android:maxLines="1"
                android:maxWidth="200dp"
                android:minLines="1"
                android:textColor="@color/white"
                android:textSize="14sp"
                tools:text="Overcast" />

            <TextView
                android:id="@+id/notification_weather_location"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:layout_toEndOf="@id/notification_weather_type"
                android:layout_toRightOf="@id/notification_weather_type"
                android:ellipsize="end"
                android:fontFamily="@string/roboto"
                android:gravity="end|bottom"
                android:maxLines="2"
                android:minLines="1"
                android:minWidth="36dp"
                android:paddingBottom="1dp"
                android:textColor="@color/ongoing_notification_small_text_color"
                android:textSize="10sp"
                tools:text="San Fransisco" />


        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/weather_location_layout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:paddingTop="2dp">

            <TextView
                android:id="@+id/notification_weather_precip"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_toLeftOf="@+id/notification_weather_time"
                android:layout_toStartOf="@+id/notification_weather_time"
                android:fontFamily="@string/roboto"
                android:gravity="top|start"
                android:maxLines="1"
                android:minLines="1"
                android:textAllCaps="true"
                android:textColor="@color/ongoing_notification_small_text_color"
                android:textSize="10sp"
                tools:text="Precip 40%" />

            <TextView
                android:id="@+id/notification_weather_time"
                android:layout_width="56dp"
                android:layout_height="match_parent"
                android:layout_alignBaseline="@+id/notification_weather_precip"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                android:fontFamily="@string/roboto"
                android:gravity="top|end"
                android:maxLines="1"
                android:minLines="1"
                android:textColor="@color/ongoing_notification_small_text_color"
                android:textSize="@dimen/gallery_grid_update_time_text_size"
                tools:text="4.00pm" />
        </RelativeLayout>
    </LinearLayout>

</RelativeLayout>

任何帮助确定此问题的根源都将非常感激

0 个答案:

没有答案