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 say which widget it had trouble loading.
I figured it out by trial and error but I would like to know if there are any places to find the error message when this occurs. Where will Android say what problem it had loading the widget or even which widget it failed to load?
I was also having the same problem -
I was using android.support.constraint.ConstraintLayout that's why it was saying "Problem loading widget" after removing this and changing to LinearLayout problem solved as @Gangnus saying, it will work for only specific views only.
I faced this problem because I was trying to use Check-box!
So,just
remove checkbox
.it will work fine.
Check elements you used in the view in a Widget..
Documentation link
A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:
And the following widget classes:
Using forbidden elements causes this very
Problem Loading Widget
message, without saying where did it happen.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.
Developer docs
My problem was: I had this Button's field which was not supported
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 anyView
results in this error.In my case I had a floating
textView
over other views. Removing it and thinking of a different way of showing my info to the user with the existing views that are not overlapping was the solution.So don't overlap views with
RelativeLayout
, I still use it and it works, but the views are not overlapping as much as possible.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.