https://kotlinlang.org logo
#glance
Title
# glance
j

James O'Claire

09/29/2023, 3:19 AM
I finally found a cause for widgets for an 'issue' causing widgets to fail when pressing 'Run App' in Android Studio. When you press 'Run App' the widget would immediately show the initial layout XML and then fail to run anything else from the widget
android:initialLayout="@layout/glance_widget_initial_layout
Finally, I realized what was causing this was the selection Run > Edit Configurations > "Always install with package manager (disables deploy optimizations on Android 11 and later". This can be recreated in the JetNews example widget: https://github.com/android/compose-samples/tree/ee198110d8a7575da281de9bd0f84e91970468ca/JetNews by selecting "Always install with package manager", adding JetNews to the home screen and pressing the 'Run App' a second time. This selection is default to false, and I had been selecting it based on some earlier tutorials like this one about developing on Glance: https://medium.com/androiddevelopers/demystifying-jetpack-glance-for-app-widgets-8fbc7041955c https://proandroiddev.com/building-a-widget-using-jetpack-glance-59317dfbfe9 @Marcel Pinto Sorry to bother you, but just curious why you originally recommended this in your blog? I don't know what that option does, but it sounds like it installs it in a way closer to what would happen regularly for a user when the app is updated from Google Play?
a

andrew

10/06/2023, 11:54 PM
That’s what this is…..
5 Views