Search code examples
androidflutterandroid-studiogradleflutter-dependencies

How do I exclude dependencies from Flutter submodule to merge with native app?


I have a native android project with a lot of submodules and custom flutter library that added as a submodule as well and dependency set up as described here: option B with settings.gradle

the issue is that some submodules are uses exoplayer, and flutter library uses it as well. so, while building I got a lot of dependency issue:

Duplicate class com.google.android.exoplayer2.video.spherical.Projection$SubMesh found in modules jetified-exoplayer-core-2.10.1-runtime (com.amazon.android:exoplayer-core:2.10.1) and jetified-exoplayer-core-2.10.1-runtime (com.google.android.exoplayer:exoplayer-core:2.10.1)

it seems force does not working in this case:

configurations.all {
    resolutionStrategy.force 'com.google.android.exoplayer:exoplayer-core:2.10.1'
}

how can I exclude exoplayer from flutter lib?

Only option I found for now is to build .arr and exclude from here, but it not working for me as flutter library also is in development.


Solution

  • replace

    implementation project(':flutter')
    

    with

    implementation(project(":flutter")) {
            exclude module: 'exoplayer-core'
            exclude module: 'exoplayer-hls'
            exclude module: 'exoplayer-dash'
            exclude module: 'exoplayer-smoothstreaming'
        }
    

    "(" and ")" around "project" is required