Repository: flutter
Issue: Android app builds are incompatible with `android.enableR8.fullMode=true`
Labels: platform-android,tool,framework,t: gradle,p: image_picker,p: firebase_performance,package,a: release,P2,team-android,triaged-android

Previous title: Android: Combination of `integration_test`, `image_picker` and `firebase_performance` and running in release mode throws `java.lang.IncompatibleClassChangeError:` exception.

### Steps to reproduce

<details open><summary>android/app/build.gradle</summary>

```
plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "com.example.test_picker"
    compileSdk flutter.compileSdkVersion
    // ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.test_picker"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
	// implementation 'androidx.core:core-ktx:1.12.0'
	// implementation 'com.android.billingclient:billing:6.1.0'
}
```

</details>


<details open><summary>android/gradle/wrapper/gradle-wrapper.properties</summary>

```
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
```

</details>

<details open><summary>android/settings.gradle</summary>

```
pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }
    settings.ext.flutterSdkPath = flutterSdkPath()

    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    // id "com.android.application" version "7.3.0" apply false
    // id "org.jetbrains.kotlin.android" version "1.7.10" apply false
    id 'com.android.application' version '8.3.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
}

include ":app"

```

</details>



<details open><summary>pubspec.yaml</summary>

```
name: test_picker
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0

environment:
  sdk: '>=3.3.3 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  image_picker: ^1.0.4

  # one
  # flutter_email_sender: ^6.0.2
  # two
  # firebase_core: ^2.16.0
  # firebase_performance: ^0.9.3+19

  # show one
  # flutter_image_compress: ^2.0.3
  # google_sign_in: ^6.2.1

  # show two
  # implementation 'com.android.billingclient:billing:6.1.0'
  # in_app_purchase: ^3.1.13

  # implementation 'androidx.core:core-ktx:1.12.0'
  # share_plus: ^8.0.2

dev_dependencies:
  integration_test:
    sdk: flutter
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.0

flutter:
  uses-material-design: true


```

</details>


1.
1.1  add to pubspec.yaml 
```
firebase_core: ^2.16.0
firebase_performance: ^0.9.3+19
```
1.2  flutter run --release

<details open><summary>Logs</summary>

```console
E/AndroidRuntime(20485): FATAL EXCEPTION: main
E/AndroidRuntime(20485): Process: com.example.test_picker, PID: 20485
E/AndroidRuntime(20485): java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'J1.a' in call to 'int J1.a.next()' (declaration of 'androidx.core.content.b' appears in base.apk)
E/AndroidRuntime(20485):        at androidx.core.content.b.h(SourceFile:1)
E/AndroidRuntime(20485):        at androidx.core.content.b.e(SourceFile:1)
E/AndroidRuntime(20485):        at androidx.core.content.b.attachInfo(Unknown Source:31)
E/AndroidRuntime(20485):        at android.app.ActivityThread.installProvider(ActivityThread.java:6391)
E/AndroidRuntime(20485):        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5938)
E/AndroidRuntime(20485):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5853)
E/AndroidRuntime(20485):        at android.app.ActivityThread.access$1100(ActivityThread.java:199)
E/AndroidRuntime(20485):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
E/AndroidRuntime(20485):        at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(20485):        at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(20485):        at android.app.ActivityThread.main(ActivityThread.java:6669)
E/AndroidRuntime(20485):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(20485):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(20485):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
```

</details>

1.3 add to pubspec.yaml 
`share_plus: ^8.0.2`

OR

add to android/app/build.gradle  (https://stackoverflow.com/questions/78049204/java-lang-incompatibleclasschangeerror-class-android-content-res-xmlblockpars)

```
dependencies {
	implementation 'androidx.core:core-ktx:1.12.0'
}
```

1.3.1 flutter run --release,  click to "Take a Photo"

<details open><summary>Logs</summary>

```console
E/AndroidRuntime(20946): FATAL EXCEPTION: flutter-worker-2
E/AndroidRuntime(20946): Process: com.example.test_picker, PID: 20946
E/AndroidRuntime(20946): java.lang.IncompatibleClassChangeError: Class 'android.content.res.XmlBlock$Parser' does not implement interface 'K1.a' in call to 'int K1.a.next()' (declaration of 'androidx.core.content.b' appears in base.apk)
E/AndroidRuntime(20946):        at androidx.core.content.b.i(SourceFile:1)
E/AndroidRuntime(20946):        at androidx.core.content.b.f(SourceFile:1)
E/AndroidRuntime(20946):        at androidx.core.content.b.g(SourceFile:1)
E/AndroidRuntime(20946):        at io.flutter.plugins.imagepicker.l$b.a(SourceFile:1)
E/AndroidRuntime(20946):        at io.flutter.plugins.imagepicker.l.R(SourceFile:1)
E/AndroidRuntime(20946):        at io.flutter.plugins.imagepicker.l.Z(SourceFile:1)
E/AndroidRuntime(20946):        at io.flutter.plugins.imagepicker.ImagePickerPlugin.a(SourceFile:1)
E/AndroidRuntime(20946):        at io.flutter.plugins.imagepicker.w.b(SourceFile:34)
E/AndroidRuntime(20946):        at io.flutter.plugins.imagepicker.s.a(SourceFile:3)
E/AndroidRuntime(20946):        at Z0.a$b.a(SourceFile:18)
E/AndroidRuntime(20946):        at Q0.c.k(SourceFile:19)
E/AndroidRuntime(20946):        at Q0.c.l(SourceFile:42)
E/AndroidRuntime(20946):        at Q0.c.h(SourceFile:1)
E/AndroidRuntime(20946):        at Q0.b.run(SourceFile:13)
E/AndroidRuntime(20946):        at Q0.c$h.d(SourceFile:21)
E/AndroidRuntime(20946):        at Q0.c$h.e(SourceFile:1)
E/AndroidRuntime(20946):        at Q0.c$h.b(SourceFile:1)
E/AndroidRuntime(20946):        at Q0.d.run(SourceFile:3)
E/AndroidRuntime(20946):        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(20946):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(20946):        at java.lang.Thread.run(Thread.java:764)
```

</details>

2. some error with "flutter_email_sender: ^6.0.2"

3. uncommented all pubspec.yaml
3.1 remove from pubspec.yaml 

```
  # integration_test:
  #   sdk: flutter
```

All ok


### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(title: 'Image Picker'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, this.title});

  final String? title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final ImagePicker _picker = ImagePicker();

  Future<void> _onImageButtonPressed(ImageSource source) async {
    try {
      final XFile? image = await _picker.pickImage(source: source);
    } on PlatformException catch (e) {
      if (e.code == 'camera_access_denied') {
        print('camera_access_denied');
      } else {
        print('Unexpected error: $e');
        rethrow;
      }
    } catch (e) {
      print('Error checking camera availability !: $e');
      rethrow;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title!),
      ),
      body: Center(
        child: FloatingActionButton(
          onPressed: () => _onImageButtonPressed(ImageSource.camera),
          tooltip: 'Take a Photo',
          child: const Icon(Icons.camera_alt),
        ),
      ),
    );
  }
}

```

</details>



### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.19045.4170], locale ru-RU)
    • Flutter version 3.19.5 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (7 days ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at G:\DB\soft_db\Android\Sdk\
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = G:\DB\soft_db\Android\Sdk\
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2023.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)

[√] VS Code (version 1.87.2)
    • VS Code at C:\Users\ooovid\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.46.0

[√] Connected device (3 available)
    • Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64    • Android 9 (API 28) (emulator)
    • Chrome (web)                          • chrome        • web-javascript • Google Chrome 123.0.6312.88
    • Edge (web)                            • edge          • web-javascript • Microsoft Edge 123.0.2420.65

[√] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>