agentleFS
abduznikabduznik/abduznik-skills/skills/flutter-android-build/SKILL.md

flutter-android-build

Skill2 starsChanged 2 months agoMITView on GitHub

Use when building Flutter APKs for Android or modifying Glance-based home screen widgets.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Don't use for: iOS builds, or general Dart/UI rendering issues (see flutter-content-rendering for HTML/PDF/WebView content quirks)

    line 28
  2. Distinctive:

    Update both of these together — they drift independently and Android will happily build with mismatched values, so nothing fails until a …

    line 33
  3. Very specific:

    If a build ships with the old version despite a pubspec.yaml bump, check local.properties first before suspecting a Gradle cache issue.

    line 43
  4. Distinctive:

    Test widget layout changes on-device or via Android Studio's widget preview — the Flutter app's own UI preview tools don't render Glance …

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flutter Android Build

Overview

Building Flutter APKs for Android and modifying Glance-based home screen widgets (Jetpack Glance, the Compose-style widget toolkit Android apps use for home_widget-style integrations).

When to Use

  • Cutting a release/debug APK build for an Android Flutter app
  • Bumping the app version ahead of a release
  • Editing or debugging a Glance home screen widget shipped alongside the app
  • Don't use for: iOS builds, or general Dart/UI rendering issues (see flutter-content-rendering for HTML/PDF/WebView content quirks)

Version Bumping

Update both of these together — they drift independently and Android will happily build with mismatched values, so nothing fails until a store upload or a widget update check compares them:

  • pubspec.yaml — the version: X.Y.Z+N line (X.Y.Z is the display version, N after the + is the build number / versionCode).
  • android/local.properties — Flutter's Gradle plugin reads flutter.versionName / flutter.versionCode overrides from here if present; if the file pins a version it will silently take precedence over pubspec.yaml at build time.

If a build ships with the old version despite a pubspec.yaml bump, check local.properties first before suspecting a Gradle cache issue.

Build Commands

flutter clean                      # when in doubt after a version/dependency change
flutter pub get
flutter build apk --release        # single universal APK
flutter build apk --release --split-per-abi   # smaller per-ABI APKs
flutter build appbundle --release  # .aab for Play Store upload
  • --split-per-abi produces app-armeabi-v7a-release.apk, app-arm64-v8a-release.apk, app-x86_64-release.apk separately under build/app/outputs/flutter-apk/ — don't sideload the wrong ABI onto a test device.
  • A release build requires a signing config (android/key.properties + matching signingConfigs block in android/app/build.gradle); without it Gradle falls back to the debug keystore and the APK will fail to update over an existing store install (signature mismatch).

Glance Widget Pitfalls

  • Glance widgets are native Kotlin/Compose code living under android/app/src/main/kotlin/**/widget/, not Dart — Flutter hot reload does not touch them. Rebuild and reinstall the APK to see widget changes. A pure Dart-side hot reload will make it look like your widget edit "did nothing."
  • Widget state updates from the Dart side (e.g. via home_widget plugin) only take effect after you explicitly call the widget update trigger from Dart; changing shared prefs/files alone does not refresh a placed widget.
  • Test widget layout changes on-device or via Android Studio's widget preview — the Flutter app's own UI preview tools don't render Glance widgets.

Dart Pitfall

substringAfter() does not exist in Dart's String API (it's a Kotlin/Guava-ism). Use .split("x").last instead, e.g. "foo=bar".split("=").last → "bar".

Common Pitfalls

  1. Version mismatch between pubspec.yaml and android/local.properties. See Version Bumping above — always grep both before assuming a version bug is a build-cache issue.
  2. Expecting hot reload to update a Glance widget. It won't — widgets are native code, not Dart.
  3. Sideloading the wrong split APK. Match the device's ABI (arm64-v8a for virtually all modern phones) or install the universal app-release.apk instead.
  4. Missing signing config on release builds. Falls back to the debug keystore silently; only surfaces as a signature-mismatch failure when updating an existing store install.

Verification Checklist

  • pubspec.yaml version and android/local.properties (if present) agree
  • flutter build apk --release (or appbundle) completes with no errors
  • Release build is signed with the real keystore, not the debug fallback
  • If a Glance widget was touched: APK reinstalled on-device, not just hot-reloaded, before judging the change

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.