【发布时间】:2022-08-23 21:10:18
【问题描述】:
在 Play 商店中更新后 Flutter 应用程序崩溃
我在谷歌游戏控制台上遇到了这种类型的错误:java.lang.IllegalAccessError
大约 20% 的用户在 Play 商店更新应用程序时出现此崩溃:
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)
这个麻烦的历史⌚->
我在使用生产应用程序时遇到问题,该应用程序在没有空安全性的颤振旧版本中已经工作了一段时间(之前)。 我已将应用程序迁移到 Flutter 的空安全版本,并添加了 android 12 兼容性。之后,我将其添加到 Play 商店的发行版中。那是应用程序版本 1.3.0,没有任何严重的崩溃案例(发布于 2022 年 2 月 21 日下午 6:21 发布于 2022 年 3 月 17 日晚上 8:20 停止,提到的崩溃案例为零)。 在那个版本的应用程序中,我有这种类型的依赖项:
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
之后,我在我的应用程序中对设计模式和状态管理进行了一些更改。我的应用程序在调试模式下没有任何错误,我已经在几个设备上对其进行了测试。没有任何崩溃并在 Play 商店推出了我的应用程序,版本名称为 2.0.0,(于 2022 年 3 月 17 日晚上 8:20 发布 于 2022 年 3 月 19 日晚上 9:39 替换,之前提到的 13.7K 案例崩溃到今天,以 40% 开始推出,我不认为这是个大问题,一天后增加到 100%),其中我有这种类型的依赖项:
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
在那之后,我感到恐慌并停止了发布。而且我已经发布了版本名称为 1.3.1 的上一个版本,因为它没有出现这种类型的崩溃。 不幸的是,这个版本的应用程序有很多相同的崩溃类型(于 2022 年 3 月 19 日下午 9:39 发布,于 2022 年 3 月 25 日下午 3:01 替换,100% 推出,因为避免了之前的崩溃,但它没用)。 在大多数手机中,某种清理过的应用程序存储或重新安装都有帮助。之后我想如果我从应用程序端清理应用程序目录和缓存日期,它不会崩溃并发布 2.0.1 版本(应用程序在大多数用户中崩溃)但它没有成功。
扑医生
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
这个应用程序有大约 25,000 名用户,总的来说它有 55,347 次相同的崩溃事件和超过 6500 名用户受到上述崩溃的影响????。
我很感谢任何帮助、建议或建议????。
我对应用程序有什么期望:
- 在生产中没有这种崩溃的应用程序(如果我在调试模式下遇到这种类型的崩溃,那就更好了)
- 任何避免这种崩溃的解决方案。
- 出了什么问题。
在我将问题发送给游戏控制台开发人员之前,他们给我邮寄了几个关于 java 错误文档和崩溃的链接,但我还没有找到任何类型的解决方案,并且在整个互联网中。
在 2022 年 7 月 4 日 6:39 之后编辑
有关我的 android/build.gradle 现在(版本 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 }我的 android/app/build.gradle 文件:
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\' }对于以前版本的 app(1.3.0) 有相同的文件,但没有任何类似的崩溃。
以及我如何在代码中使用 cached_network_image :
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, ), ),
-
请提供您在哪里实例化和访问数据库的代码,以便有更好的机会帮助您解决这个问题。
-
@DanHarms 不幸的是我没有写任何数据库代码,只有 cached_network_image->flutter_cache_manager-> sqflite 包使用 sqlite,我在他们的存储库中搜索了类似的问题,但没有找到任何东西
-
我不确定,但请尝试将 build.gradle 文件中的 Android Gradle 插件降级到 3.6.2
-
@SarthakRaval,不幸的是,由于颤动的firebase消息传递,我无法降级它,这需要更高的kotlin和gradle版本,起初1.3.0版本的应用程序运行良好,并且它具有与现在相同的gradle文件。
标签: java flutter google-play android-sqlite crashlytics-android