Troubleshooting
build_runner runs but no files are generated
- Make sure your widget definition file is under
lib/(notbin/,test/, orexample/) - Make sure the variable is
finalorconst, declared at the top level (not inside a function or class) - Make sure the type is exactly
AndroidWidget(not a typedef or alias) - Check build output for
Found N AndroidWidget(s) in ...— if missing, the file was not scanned
Run with --verbose for more detail:
dart run build_runner build --verbose"Build failed due to use of deleted Android v1 embedding"
Add to AndroidManifest.xml inside <application>:
<meta-data
android:name="flutterEmbedding"
android:value="2" />Manifest not patched
Make sure both marker comments are present inside <application> in AndroidManifest.xml:
<!-- flutter_android_widgets:start -->
<!-- flutter_android_widgets:end -->They must be:
- Inside
<application>(not inside<activity>) - Spelled exactly as above, including the spaces before the double-dash
Widget not appearing in the widget picker
- Make sure
flutter build apk(orflutter run) succeeded without errors - Verify the
<receiver>entry is inAndroidManifest.xmlbetween the markers - On some launchers you need to restart the launcher or reboot after installing a debug APK
Widget shows "Problem loading widget" on the home screen
- Run
flutter build apk --debugand verify it compiles - Check the generated Kotlin file has the correct package name at the top (should match your app's package)
- Verify the layout XML only uses RemoteViews-compatible views (no custom views, no
RecyclerView) - Check logcat for crash stacks:
adb logcat | Select-String "Widget|AppWidget|RemoteViews"SharedPreferences data not appearing
Debug checklist:
- Are you using
HomeWidgetData.save()? (not rawSharedPreferences) - Does the key match an entry in your widget's
dataKeyslist? - Does the key match a
\${key}placeholder in aWText? - Has the widget refreshed after saving? (Enable
HomeWidgetData.autoUpdate = true, tap Refresh, or wait for the interval) - Does
HomeWidgetData.read('yourKey')return the expected value in Flutter?
Style changes not appearing after hot restart
- Make sure you passed
widgets: [myWidget]toWidgetUpdater.initialize() - Make sure you used hot restart (
Ctrl+Shift+F5), not hot reload — hot reload does not re-evaluate top-levelfinalvariables - Verify the widget on the home screen refreshed (you should see a flicker)
"Conflicting outputs" error from build_runner
Run with the delete flag:
dart run build_runner build --delete-conflicting-outputsminWidth/minHeight change not taking effect
Size metadata is compiled into the APK and cached by the launcher at placement time. After changing:
dart run build_runner build
flutter run # reinstalls APKThen remove the widget from the home screen and re-add it. The launcher will read the new size from the freshly installed APK.
Button tap has no effect
- Make sure the
actionKeyis non-empty and unique across all your widgets - Check that
FlutterAndroidWidgetsChannel.ktwas generated (in thekotlin/directory) - Check that
MainActivity.ktwas patched to register the channel (look forFlutterAndroidWidgetsChannel.configure() - Check logcat for
ACTION_<ACTIONKEY>broadcast not being received
Test coverage
The package includes 89 unit tests across 6 files:
| File | Tests | Coverage |
|---|---|---|
xml_generator_test.dart | 13 | All node types, escaping, namespaces |
kotlin_generator_test.dart | 8 | Kotlin output, bindings, PendingIntent |
manifest_patcher_test.dart | 9 | Patching, re-patching, multiple widgets |
widget_analyzer_test.dart | 10 | Discovery, analysis, layout parsing |
data_model_test.dart | 37 | Enums, WidgetInfo, WidgetNode, NodeCollector |
channel_generator_test.dart | 12 | Channel generation, MainActivity patching |
Run all tests from the package root:
flutter test