[Bug]: [Android] Release build crashes on launch with AGP 9: R8 removes WorkDatabase_Impl constructor (Room 2.6.1 keep rule)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start by reading the plugin’s Android proguard-rules.pro and checking how its rules are included in the release build. Reproduce with AGP 9 and minification enabled, then confirm the Room WorkDatabase_Impl constructor is retained in the R8 output. Done when the release app launches successfully with the keep rule in place.
Written by the indexing model from the issue text.
Description
Required Reading
- Confirmed
Plugin Version
5.8.0
Flutter Doctor
[✓] Flutter (Channel stable, 3.47.6, on macOS 26.6.2 25G83 darwin-arm64, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
! Multiple adb binaries found.
! Some Android licenses not accepted.
[!] Xcode - develop for iOS and macOS (Xcode 27.0)
! iOS 27.0 Simulator not installed.
[✓] Chrome - develop for the web
[✓] Connected device (6 available)
[✓] Network resources
Android Gradle Plugin 9.4.0, Gradle 9.6.0, Kotlin 2.3.20
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
Google Pixel 9 Pro (emulator); affects every device
Device operating-systems(s)
Android 17
What happened?
With Android Gradle Plugin 9 and minifyEnabled, our release build crashes on launch, before Flutter starts. Debug builds are fine.
R8 removes the no-arg constructor of androidx.work.impl.WorkDatabase_Impl. Room creates that class by reflection, so androidx.startup fails to initialize WorkManager (see log output).
Dependency chain:
com.transistorsoft:tslocationmanager:4.6.4 (also 4.7.6, the latest)
\--- androidx.work:work-runtime:2.10.0
\--- androidx.room:room-runtime:2.6.1
Room 2.6.1 ships only -keep class * extends androidx.room.RoomDatabase. With AGP 9, R8 no longer keeps the default constructor for a class-only -keep rule (android.r8.strictFullModeForKeepRules is on by default). Room 2.7 fixed this in its own consumer rules ({ void <init>(); }). WorkManager 2.11+ depends on Room 2.7, but tslocationmanager still pins work-runtime:2.10.0.
R8's usage.txt confirms the removal:
androidx.work.impl.WorkDatabase_Impl:
public void <init>()
Expected: a release build with AGP 9 starts normally.
Suggested fix: add this rule to the plugin's android/proguard-rules.pro (or the SDK's consumer rules). It is the same rule Room 2.7 ships:
-keep class * extends androidx.room.RoomDatabase { void <init>(); }
We added it to our app's proguard-rules.pro and the release build starts again. Upgrading to work-runtime 2.11+ would also fix it, but I saw in #1622 that it requires a higher compileSdk.
Plugin Code and/or Config
// Not plugin config: release build type in android/app/build.gradle.kts
release {
isMinifyEnabled = true
isShrinkResources = false
proguardFiles(
file("${backgroundGeolocation.projectDir}/proguard-rules.pro"),
file("proguard-rules.pro"),
)
}
Relevant log output
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider
E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:9191)
E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:8668)
E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:8293)
E AndroidRuntime: ...
E AndroidRuntime: Caused by: lv3: java.lang.NoSuchMethodException: androidx.work.impl.WorkDatabase_Impl.<init> []
E AndroidRuntime: at pf.b(r8-map-id-1c2fcce569c11920677ba238b5dacd04c72d330822c128ef38e423dbeb5cd5b6:104)
E AndroidRuntime: at pf.a(r8-map-id-1c2fcce569c11920677ba238b5dacd04c72d330822c128ef38e423dbeb5cd5b6:86)
E AndroidRuntime: at androidx.startup.InitializationProvider.onCreate(r8-map-id-1c2fcce569c11920677ba238b5dacd04c72d330822c128ef38e423dbeb5cd5b6:55)
E AndroidRuntime: at android.content.ContentProvider.attachInfo(ContentProvider.java:2695)
- Dominant language
- Dart
- Stars
- 732
- Forks
- 287
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from transistorsoft/flutter_background_geolocation
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
transistorsoft/flutter_background_geolocation#1721 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 8/100
transistorsoft/flutter_background_geolocation#1719 · 8 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
transistorsoft/flutter_background_geolocation#1718 · 1 comment ·
All issues in transistorsoft/flutter_background_geolocation
Similar issues
-
@apps/catalog enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ymm-oss/flutter-mobile-project-template#699 ·
Maintainers usually reply within 15 days
-
area::build area::tests
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
linagora/twake-on-matrix#3504 · 1 comment ·
Maintainers usually reply within 3 days
-
[Packages] [flutter_shaders] InkWell shader golden test fails on Flutter stable and Master channelsOpenfrom: manual-qa
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
espresso3389/pdfrx#777 ·
Maintainers usually reply within 4 days
-
README highlightsOpendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
patarapolw/lingua_srs#22 ·