java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'la.a'

189 Views Asked by At

I have a flutter app which I have recently upgraded to Gradle 8. Ever since I have upgraded my app crashes on startup but only in release mode. I believe it is one of my packages causing the problem but I have no idea which one.

Here is the full error:

E/AndroidRuntime(21410): FATAL EXCEPTION: main
E/AndroidRuntime(21410): Process: com.project.myproject, PID: 21410
E/AndroidRuntime(21410): java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'la.a' in call to 'int la.a.next()' (declaration of 'androidx.core.content.f' appears in /data/app/com.pavemotors.paveplus-1V1FH1D8p_zC2xK_nPBRAg==/base.apk)
E/AndroidRuntime(21410):        at androidx.core.content.f.h(Unknown Source:19)
E/AndroidRuntime(21410):        at androidx.core.content.f.e(Unknown Source:11)
E/AndroidRuntime(21410):        at androidx.core.content.f.attachInfo(Unknown Source:31)
E/AndroidRuntime(21410):        at android.app.ActivityThread.installProvider(ActivityThread.java:7273)
E/AndroidRuntime(21410):        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6813)
E/AndroidRuntime(21410):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6699)
E/AndroidRuntime(21410):        at android.app.ActivityThread.access$2000(ActivityThread.java:273)
E/AndroidRuntime(21410):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2020)
E/AndroidRuntime(21410):        at android.os.Handler.dispatchMessage(Handler.java:112)
E/AndroidRuntime(21410):        at android.os.Looper.loop(Looper.java:216)
E/AndroidRuntime(21410):        at android.app.ActivityThread.main(ActivityThread.java:7625)
E/AndroidRuntime(21410):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(21410):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
E/AndroidRuntime(21410):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

My packages have all been updated to latest and listed below:

  app_tracking_transparency: ^2.0.4
  auto_size_text: ^3.0.0
  bip32: ^2.0.0
  bip39: ^1.0.6
  cached_network_image: ^3.3.1
  cloud_firestore: 4.15.5
  cloud_functions: 4.6.5
  collection: ^1.18.0
  connectivity_plus: ^5.0.2
  cupertino_icons: ^1.0.6 # The following adds the Cupertino Icons font to your application.
  encrypt: ^5.0.1
  equatable: ^2.0.5
  firebase_auth: 4.17.5
  firebase_auth_mocks: ^0.13.0
  firebase_core: 2.25.4
  firebase_messaging: 14.7.16
  firebase_storage: 11.6.6
  flutter:
    sdk: flutter
  flutter_launcher_icons: ^0.13.1
  flutter_reactive_ble: 5.3.1
  flutter_riverpod: 2.4.10
  flutter_secure_storage: ^9.0.0
  flutter_svg: ^2.0.9
  fluttertoast: ^8.2.4
  font_awesome_flutter: ^10.5.0
  gap: ^3.0.1
  geolocator: ^11.0.0
  get_storage: ^2.1.1
  go_router: 13.2.0
  google_maps_flutter: 2.5.3
  google_sign_in: 6.2.1
  http: ^1.2.0
  image: ^4.1.6
  image_cropper: ^5.0.0
  image_picker: ^1.0.7
  lints: ^3.0.0
  local_auth: ^2.1.8
  logger: ^2.0.2+1
  permission_handler: 10.4.5
  provider: ^6.0.2
  qr_flutter: ^4.1.0
  quiver: ^3.2.1
  riverpod_annotation: 2.3.3
  riverpod_lint: 2.3.9
  rxdart: ^0.27.7
  sign_in_with_apple: ^5.0.0
  slide_to_act: ^2.0.2
  sqflite: 2.3.2
  time: ^2.1.4
  url_launcher: ^6.2.3
  vibration: ^1.8.4
  weather: ^3.1.1
  web3dart: 2.7.2

Here is my build.gradle:

buildscript {
    ext.kotlin_version = '1.8.21'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

My project works perfectly in debug mode. It fails when releasing to play store and running with flutter run --release

2

There are 2 best solutions below

0
wwwwww3q On

it works for me android/app/build.gradle

add this to dependencies

def core_version = "1.12.0"
implementation "androidx.core:core-ktx:$core_version"

Link: https://developer.android.com/jetpack/androidx/releases/core?hl=en

0
John Osborn On

While @wwwwww3q answer fixes the crash at startup, there was still a related crash in the share_plus plugin. Adding the following proguard statement fixed both crashes for me:

-keep class org.xmlpull.v1.** { *; }