firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.43k stars 3.9k forks source link

[firebase_core][firebase_auth]: Execution failed for task ':app:mergeLibDexDebug'. #12704

Closed ndson040496 closed 1 week ago

ndson040496 commented 1 week ago

Is there an existing issue for this?

Which plugins are affected?

Core, Auth

Which platforms are affected?

Android

Description

My project couldn't build to Android after adding firebase_core and firebase_auth. iOS and Web can still build and run just fine.

Reproducing the issue

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.sseo.app_incent" 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 {
    applicationId "com.sseo.app_incent"
    // 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 34
    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 {}


- My pubspec.yaml

name: app_incent description: "A new Flutter project." publish_to: 'none' version: 0.1.0

environment: sdk: '>=3.3.4 <4.0.0'

dependencies: firebase_auth: 4.19.4 firebase_core: 2.30.1 flutter: sdk: flutter flutter_localizations: sdk: flutter go_router: 14.0.0 intl: any

dev_dependencies: flutter_test: sdk: flutter flutter_lints: 3.0.2

flutter: assets:



### Firebase Core version

2.30.1

### Flutter Version

3.19.6

### Relevant Log Output

_No response_

### Flutter dependencies

_No response_

### Additional context and comments

_No response_
russellwheatley commented 1 week ago

Hey @ndson040496, I just ran the same command for the auth example app. It was successful:

[+1326 ms] βœ“  Built build/app/outputs/flutter-apk/app-debug.apk.
[        ] "flutter apk" took 51,421ms.
[ +123 ms] ensureAnalyticsSent: 107ms
[        ] Running 0 shutdown hooks
[        ] Shutdown hooks complete
[  +18 ms] exiting with code 0

It looks like you have a configuration issue, looking at your build logs:

           β”Œβ”€ Flutter Fix 
           β”‚ [!] The shrinker may have failed to optimize the Java bytecode.            β”‚
           β”‚ To disable the shrinker, pass the `--no-shrink` flag to this command.      β”‚
           β”‚ To learn more, see: https://developer.android.com/studio/build/shrink-code β”‚

This article might be of assistance to you: https://stackoverflow.com/questions/60745249/the-shrinker-may-have-failed-to-optimize-the-java-bytecode

ndson040496 commented 1 week ago

I have added --no-shrink to the command but it still fails flutter build apk --debug --verbose --no-shrink

Also added the no shrink options to config to build.gradle, but no luck:

    buildTypes {
        release {
            signingConfig signingConfigs.debug
            shrinkResources false
            minifyEnabled false
        }
    }

The article mostly points to the minSdkVersion which I already set to 21 (already tried with every number from 21 to 34, all fail).

The Java version on my Mac is Java 21, could this be the reason? should I downgrade it to Java 8 so that it matches the one in build.gradle?

russellwheatley commented 1 week ago

I doubt downgrading is the fix, but worth a try. I am on Java 17 if that helps.

ndson040496 commented 1 week ago

@russellwheatley Java 17 solved the problem for me. So looks like flutterfire is not compatible with newer Java