Android 添加多个DFM时,动态功能模块google services会出现问题

Android 添加多个DFM时,动态功能模块google services会出现问题,android,google-play-services,Android,Google Play Services,我正在对我们的应用程序进行模块化,并为按需下载实现Android新的动态功能模块。我能够成功地添加feature1,但是,当我添加feature2时,出现以下错误: [:feature1, :feature2] all package the same library [com.google.android.gms:play-services-location-license]. [:feature1, :feature2] all package the same library [com.g

我正在对我们的应用程序进行模块化,并为按需下载实现Android新的动态功能模块。我能够成功地添加feature1,但是,当我添加feature2时,出现以下错误:

[:feature1, :feature2] all package the same library [com.google.android.gms:play-services-location-license].
[:feature1, :feature2] all package the same library [com.google.firebase:firebase-messaging-license].

Multiple APKs packaging the same library can cause runtime errors.
Adding the above library as a dependency of the base module will resolve this
issue by packaging the library with the base APK instead.
我的DFMs唯一用作依赖项的是
:app
。当我查找这些许可依赖项时,它们不存在于我的任何gradle文件中。我们目前使用的是android gradle版本3.5.2。以下是
:app
模块的依赖项片段:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'jacoco'

dependencies {
    def nav_version = "2.1.0"
    implementation 'androidx.fragment:fragment:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.2.0-alpha01'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.browser:browser:1.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    implementation 'com.google.android.play:core:1.6.4'
    implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
        transitive = true
    }
    implementation 'com.onesignal:OneSignal:3.11.4'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-3'
    implementation 'com.squareup.picasso:picasso:2.71828'

    implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.60"
}
我如何解决这个问题?我假设这一定是由于谷歌服务的一个相互依赖项包含相同的内容,即
play core
gms
、和
firebase
,但我不知道。文档中说DFM必须依赖于您的基本模块(在我的例子中,
:app
),所以这对我来说似乎很奇怪。如果你能帮我解决这个问题,我将不胜感激

谢谢~


编辑:feature1和feature2都有两个依赖项:所需的插件
应用插件:'com.android.dynamic feature'
实现项目(':app')

在对我的DFM的依赖结构进行了一些实验和挖掘之后,我意识到我必须在DFM中包含一个单独的
google.json
文件。一旦我添加了这一点,gradle就不再抱怨重复许可。

这意味着你的功能1和功能2带来了相同的库,但你的基本模块(即应用程序)没有该库,因此在打包时,它不知道应该采用哪个版本。因此,要修复它,您必须将特定的库添加到您的应用程序梯度。这两个功能带来的基础模块没有的唯一依赖项是
apply plugin:'com.android.dynamic feature'
您可以发布功能1和功能2的依赖项吗?他们可能正在使用上述DependenciedPost的不同版本来包含依赖项