“_Problem Loading Widget” message

前端 未结 18 1742
旧巷少年郎
旧巷少年郎 2021-02-02 06:08

When loading a widget if it cannot find a resource or something it says Problem Loading Widget. That\'s all! Amazing! This message remains on the home screen and does not even s

相关标签:
18条回答
  • 2021-02-02 06:30

    In my case error was caused by changed provider class name. So if you have changed the name of Widget Provider class, try to change it back. Also, if you have changed the names of xml files (ex. widget_info.xml, widget_layout.xml), you might want to change those back as well.

    This happened only when user updated app and "old" widget was currently visible.

    0 讨论(0)
  • 2021-02-02 06:33

    As said in comments, check logcat. What you will see is a NullPointerException. I have had this before too.

    0 讨论(0)
  • 2021-02-02 06:34

    I also face this problem but only due to heavy widget layout. Widget Layout should be light as much you can create. Now my widget working perfect.

    0 讨论(0)
  • 2021-02-02 06:35

    Just for the record. I have a FrameLayout with a TextView inside, all content in a LinerLayout, that would be the header of my widget. Initially I had this

    <LinearLayout
    [...] 
    
    <FrameLayout
        android:id="@+id/widget"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="@string/app_name"
            android:layout_margin="@dimen/activity_horizontal_margin"
            android:textColor="@android:color/white"/>
    </FrameLayout>
    
    [...] 
    </LinearLayout>
    

    As everyone here, I had the "Problem loading widget" message. The solution was change this

        android:layout_height="?attr/actionBarSize"
    

    for this:

        android:layout_height="64dp"
    
    0 讨论(0)
  • 2021-02-02 06:38

    Problem Loading the widget results from problem/s in your widget layout!

    There are only limited amount of resource you can use in the widget.Make sure you use the proper elements and their fields.

    A RemoteViews object (and, consequently, an App Widget) can support the following ... widget classes:

    AnalogClock
    Button
    ...
    

    Developer docs

    My problem was: I had this Button's field which was not supported

    android:onClick="onClick" 
    

    Deleting this enabled the widget to appear where placed (if placed previously) and in the menu of available widgets.

    In fact setting android:onClick= for any View results in this error.

    0 讨论(0)
  • 2021-02-02 06:42

    A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:

    FrameLayout
    LinearLayout
    RelativeLayout
    GridLayout
    

    And the following widget classes:

    AnalogClock
    Button
    Chronometer
    ImageButton
    ImageView
    ProgressBar
    TextView
    ViewFlipper
    ListView
    GridView
    StackView
    AdapterViewFlipper
    

    Anything using other than above causes this so called "Problem Loading widget".

    Moreover, check logs (without any filter) to see exact line of this problem.

    0 讨论(0)
提交回复
热议问题