Embedding a flutter module fails as of version 3.3.x in custom build type

This issue has been tracked since 2022-11-25.

We have built a Flutter module for a particular feature that we want to share with our natively build iOS and Android apps. So far that all worked fine, however today we are experiencing an issue when building the Android application.

For Android in particular our setup is (and has always been) done with the repo linking. So from our Android project we link to the Flutter module by adding this dependency management in our app/build.gradle (where this FlutterModuleProject is always physically located in the same parent-directory as the Android project):

String storageUrl = "https://storage.googleapis.com"
repositories {
    maven {
        url '../FlutterFeed/build/host/outputs/repo'
    }
    maven {
        url "$storageUrl/download.flutter.io"
    }
    mavenCentral()
}

Then we 'link' in the flutter module dependency like this:

    debugImplementation 'com.company.fluttermoduleproject:flutter_debug:+'
    acceptanceImplementation 'com.tricount.tricountflutterfeedmodule:flutter_release:+'
    releaseImplementation 'com.company.fluttermoduleproject:flutter_debug:flutter_release:+'

The custom build type acceptance is configured based on debug:

        acceptance.initWith(buildTypes.debug)
        acceptance {
            debuggable false
            minifyEnabled true
            applicationIdSuffix '.acceptance'
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            matchingFallbacks = ['debug']
        }

So the purpose of the acceptance build type is to generate build that can be tested and approved by our test-team internally, running only against a test-environment backend, not debuggable anymore and with minify (obfuscation etc) already fully enabled. The proguard file it uses is the same as the one used for the production build.

So again, this all used to work in 3.0.x. It only started failing (as you'll see below) after we upgraded to Flutter 3.3.8/3.3.9.

The way we build the project is by first building the flutter module:

flutter clean
flutter pub get
flutter build aar

That all goes well. After that we simply build our Android project in either debug or release:

./gradlew assembleDebug
./gradlew assembleRelease

Both work well, the problem only appears when building in this custom build type acceptance:

./gradlew assembleAcceptance

And here the issue appears when building the debug variant. For release it all works fine. We get like a lot of errors so I will attach the full error log, however the last few error lines look like this (and they all look familiar):

     Duplicate class io.flutter.view.VsyncWaiter found in modules jetified-flutter_embedding_debug-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_debug:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99) and jetified-flutter_embedding_release-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_release:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99)
     Duplicate class io.flutter.view.VsyncWaiter$1 found in modules jetified-flutter_embedding_debug-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_debug:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99) and jetified-flutter_embedding_release-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_release:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99)
     Duplicate class io.flutter.view.VsyncWaiter$1$1 found in modules jetified-flutter_embedding_debug-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_debug:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99) and jetified-flutter_embedding_release-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_release:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99)
     Duplicate class io.flutter.view.VsyncWaiter$DisplayListener found in modules jetified-flutter_embedding_debug-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_debug:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99) and jetified-flutter_embedding_release-1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99 (io.flutter:flutter_embedding_release:1.0.0-8f2221fbef28b478debb78dd233f5250b220ca99)

To me (definitely since it only happens in custom variant building) it seems like there is either missing some obfuscation configuration or the dependency management is poorly defined causing multiple variants to become available on the classpath of the embedding library.

Attached you can find the full build log file of the ./gradlew assembleAcceptance command.
Note: you can see there is a variant Google and Huawei to either build a Google specific or Huawei specific AAB or APK. But executing the command for one specific variant (eg. ./gradlew assembleGoogleAcceptance) does not make any difference.

log.txt

exaby73 wrote this answer on 2022-11-25

Hello @dirkvranckaert. Could you provide a complete and minimal, reproducible example in the form of a public repo with detailed reproduction steps so that I may verify the issue?

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-12-07
Star Count 147031
Watcher Count 3560
Fork Count 23915
Issue Count 11300

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date