This https://developer.android.com/guide/topics/appwidgets/#preview says
To help create a preview image for your app widget (to specify in the previewImage field), the Android emulator includes an application called "Widget Preview." To create a preview image, launch this application, select the app widget for your application and set it up how you'd like your preview image to appear, then save it and place it in your application's drawable resources.
I can't find this application on the latest Android system image, Android Oreo (8.1) API 27
This question has been asked and answered here, Widget preview image, but the application is missing.
So how do I generate a preview image?
The most common reason for a widget to disappear is when Android users transfer applications to a memory card. Widgets may also disappear after the hard reboot of your device. To return it, you need to transfer them again to the phone's memory.
To re-add the same widget, tap and hold on an empty space on your home screen, tap Widgets, and select the one you want.
The Widget Preview app will only show up when running an older version of Android on an emulator (API 26 or lower).
If the Widget Preview isn't showing up on your emulator, you need to create a new Virtual Device with a lower API in Android Studio:
1) Tools>AVD Manager>Create Virtual Device...
2) Select the device you'd like to use, click "Next"
3) In the next window, select Nougat, API Level 25. You may need to download it if you've never used it before. Click "Next", then "Finish"
4) Run the app on the new virtual device, and search for the Widget Preview again
After the preview has been created, the emulator gives you the option of emailing it so you can save it locally and later to the drawables folder of your project.
Hope that solves it for you too!
Future readers, I solved this by using an older android version system image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With