Flutter app crashes after update in play store
I had massive amount of crash at google play console with this type of error: java.lang.IllegalAccessError
About 20% of user had this crash when updated app at play store:
java.lang.IllegalAccessError:
at androidx.room.v.e (Unknown Source:15)
at d.h.a.k.e.onUpgrade (:2)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:354) // line number is different in some crashes
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:250)
at d.h.a.k.e.c (Unknown Source:4)
at d.h.a.k.f.N (Unknown Source:4)
at androidx.room.s.k (Unknown Source:2)
at androidx.room.s.b (Unknown Source)
at androidx.work.impl.D.j.b (Unknown Source:9)
at androidx.work.impl.background.systemjob.b.i (Unknown Source:20)
at androidx.work.impl.utils.f.a (:1)
at androidx.work.impl.utils.f.run (Unknown Source:31)
at androidx.work.impl.utils.k.run (Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
at java.lang.Thread.run (Thread.java:784)
History of this trouble ⌚->
I'm having trouble with production app, which has been working for a while in flutter old version without null safety(before). I have migrate app into null safety version of flutter, and added android 12 compatibility. After that I have added it into release at play store. That was app version 1.3.0 and there wasn't any massive case of crash (released at Feb 21, 2022 6:21 PM Rollout halted on Mar 17, 2022 8:20 PM, zero case of mentioned crash). In that version of app I had this types of dependencies:
auto_orientation: ^2.2.0
cached_network_image: ^3.2.0
connectivity: ^3.0.6
dio: ^4.0.4
dio_http_cache: ^0.3.0
dotted_line: ^3.1.0
path_provider: ^2.0.8
firebase_analytics: ^9.0.5
firebase_messaging: ^11.2.5
flutter_html: ^2.2.1
google_mobile_ads: ^1.0.1
video_player: ^2.2.15
hive: ^2.0.5
hive_flutter: ^1.1.0
photo_view: ^0.13.0
provider: ^6.0.2
pull_to_refresh: ^2.0.0
scrollable_positioned_list: ^0.2.3
share: ^2.0.4
shared_preferences: ^2.0.11
shimmer: ^2.0.0
sqflite: ^2.0.1
url_launcher: ^6.0.17
After that I made some changes in design pattern and state managment in my app. My app was working without any kind of error in debug mode, I have tested it in couple of devices. There wasn't any crash and rolled out my app at play store with version name 2.0.0, (released at Mar 17, 2022 8:20 PM Replaced on Mar 19, 2022 9:39 PM, 13.7K case of before mentioned crash till today, started rollout at 40% and I haven't thought it was big problem, after one day increased into 100%) in which I had this types of dependencies:
auto_orientation: ^2.2.0
cached_network_image: ^3.2.0
chewie: ">=1.1.0 <1.1.1"
connectivity_plus: ^2.2.1
equatable: ^2.0.3
dio: ^4.0.4
dio_cache_interceptor: ^3.2.6
dio_cache_interceptor_hive_store: ^3.1.1
ferry: ^0.10.4
firebase_analytics: ^9.0.5
firebase_messaging: ^11.2.5
flutter_html: ^2.2.1
provider: ^6.0.2
google_mobile_ads: ^1.0.1
hive: ^2.0.5
path_provider: ^2.0.9
photo_view: ^0.13.0
pull_to_refresh: ^2.0.0
scrollable_positioned_list: ^0.2.3
share_plus: ^3.0.5
shared_preferences: ^2.0.13
shimmer: ^2.0.0
url_launcher: ^6.0.20
After that I had panic and halted that release. And I have released into productuion previous release with version name 1.3.1, because it hasn't this type of crash. Unfortunatly this version of app had plenty amount of same crash type(released at Mar 19, 2022 9:39 PM Replaced on Mar 25, 2022 3:01 PM, rollout at 100% because avoid previous crash but it was useless). Some kind of cleaned app storage or reinstalling helped in most of phones. After that I thought if I clean app directories and cache date from app side, it won't crash and released 2.0.1 version(App is getting crash in most of users) but it wasn't succesfull.
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.22000.493], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 4.1)
[√] VS Code (version 1.65.2)
[√] Connected device (3 available)
[√] HTTP Host Availability
This app ha about 25K users, in summary it had 55,347 same crash occurrences and more than 6500 useres impacted with mentioned crash .
I'm thankfull for any help, suggestions or advises .
What do I expect from app:
- App without this kind of crash in production (if I had this type of crash in debug mode it was way better)
- Any kind of solution to avoid this crash.
- What was wrong with it.
Before I had send issue into play console devs and they mailed me couple of links about java error documentation and about crashes but I haven't found any kind of solution there are and in the entire of internet.
Edit after 6:39 07-04-2022
For more detail about my android/build.gradle for now(version 2.0.x):
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My andorid/app/build.gradle file:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '2'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.<company_name>.<app_name>"
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:2.0.1'
implementation platform('com.google.firebase:firebase-bom:29.0.4')
implementation 'com.google.firebase:firebase-analytics'
// implementation 'com.google.android.gms:play-services-ads:20.5.0'
implementation 'androidx.cardview:cardview:1.0.0'
}
For previous version of app(1.3.0) had same file but hasn't had any similar crash.
And for how I use cached_network_image in my code:
CachedNetworkImage(
imageUrl: widget.post.imageUrl,
width: double.infinity,
fit: BoxFit.cover,
placeholder: (url, ctx) => const BigImageShimmer(),
errorWidget: (context, url, error) => Image.asset(
'assets/images/error_image.png',
fit: BoxFit.cover,
color:
Theme.of(context).textTheme.bodyText1?.color,
),
),