title: Flutter app gets crash after update: java.lang.IllegalAccessError, how to avoid this problem?
body: <h2>Flutter app crashes after update in play store</h2>
  <p>I had massive amount of crash at google play console with this type of error: java.lang.IllegalAccessError</p>
  <p>About 20% of user had this crash when updated app at play store:</p>
  <pre><code>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)
  </code></pre>
  <h3>History of this trouble ⌚-&gt;</h3>
  <p>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:</p>
  <pre><code>  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
  </code></pre>
  <p>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:</p>
  <pre><code>  auto_orientation: ^2.2.0
    cached_network_image: ^3.2.0
    chewie: &quot;&gt;=1.1.0 &lt;1.1.1&quot;
    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
  </code></pre>
  <p>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.</p>
  <h3>flutter doctor</h3>
  <pre><code>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 &quot;Desktop development with C++&quot; 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
  </code></pre>
  <h4>This app ha about 25K users, in summary it had 55,347 same crash occurrences and more than 6500 useres impacted with mentioned crash .</h4>
  <h4>I'm thankfull for any help, suggestions or advises .</h4>
  <h4>What do I expect from app:</h4>
  <ol>
  <li>App without this kind of crash in production (if I had this type of crash in debug mode it was way better)</li>
  <li>Any kind of solution to avoid this crash.</li>
  <li>What was wrong with it.</li>
  </ol>
  <p>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.</p>
  <h2>Edit after 6:39 07-04-2022</h2>
  <p>For more detail about my android/build.gradle for now(version 2.0.x):</p>
  <pre><code>buildscript {
      ext.kotlin_version = '1.5.10'
      repositories {
          google()
          mavenCentral()
      }
  
      dependencies {
          classpath 'com.android.tools.build:gradle:4.1.0'
          classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
          classpath 'com.google.gms:google-services:4.3.2'
      }
  }
  
  allprojects {
      repositories {
          google()
          mavenCentral()
      }
  }
  
  rootProject.buildDir = '../build'
  subprojects {
      project.buildDir = &quot;${rootProject.buildDir}/${project.name}&quot;
  }
  subprojects {
      project.evaluationDependsOn(':app')
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  <p>My andorid/app/build.gradle file:</p>
  <pre><code>def localProperties = new Properties()
  def localPropertiesFile = rootProject.file('local.properties')
  if (localPropertiesFile.exists()) {
      localPropertiesFile.withReader('UTF-8') { reader -&gt;
          localProperties.load(reader)
      }
  }
  
  def flutterRoot = localProperties.getProperty('flutter.sdk')
  if (flutterRoot == null) {
      throw new GradleException(&quot;Flutter SDK not found. Define location with flutter.sdk in the local.properties file.&quot;)
  }
  
  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: &quot;$flutterRoot/packages/flutter_tools/gradle/flutter.gradle&quot;
  
  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 &quot;com.&lt;company_name&gt;.&lt;app_name&gt;&quot;
          // 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 &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
      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'
  }
  </code></pre>
  <p>For previous version of app(1.3.0) had same file but hasn't had any similar crash.</p>
  <p>And for how I use cached_network_image in my code:</p>
  <pre class="lang-dart prettyprint-override"><code>CachedNetworkImage(
    imageUrl: widget.post.imageUrl,
    width: double.infinity,
    fit: BoxFit.cover,
    placeholder: (url, ctx) =&gt; const BigImageShimmer(),
    errorWidget: (context, url, error) =&gt; Image.asset(
      'assets/images/error_image.png',
      fit: BoxFit.cover,
      color:
          Theme.of(context).textTheme.bodyText1?.color,
    ),
  ),
  </code></pre>