Widget is shown as 0x0 and crashes Launcher
-
27-10-2019 - |
Question
So, I have declared a widget for my app and wanted to try it on the Ice Cream Sandwich emulator, however when I select it, it crashes the launcher.
The problem is, that the launcher thinks width and heigt would equal 0 (it also lists my widget as a 0x0 widget), so I guess there is a problem in my declaration
E/AndroidRuntime( 709): java.lang.IllegalArgumentException: width and height must be > 0
E/AndroidRuntime( 709): at android.graphics.Bitmap.createBitmap(Bitmap.java:603)
E/AndroidRuntime( 709): at android.graphics.Bitmap.createBitmap(Bitmap.java:585)
[...]
This is my widget declaration:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android">
android:updatePeriodMillis="7200000"
android:initialLayout="@layout/widget"
android:minHeight="72dp" android:minWidth="90dp">
</appwidget-provider>
Is there something wrong with minHeight
and minWidth
?
Solution
Just in case someone made the same mistake: This was due to a syntax error (see comments above) the compiler didn't recognize.
OTHER TIPS
Yet another way to trigger the same error is to set android:previewImage
to a dimensionless shape drawable in the my_widget_info.xml
file and not to a png.
Solved by setting android:previewImage
to a drawable with dimensions, for example any .png.
At first I thought it would be clever to use the background shape drawable as a placeholder preview image while working on my widget, which is why I got this error.