unity接入firebase分析和google登录冲突解决

unity版本2018.4
play-services-resolver_v1.2.124.0

gradle版本3.4
targetSdkVersion 28

unity要接入sdk,先在Firebase去下载了unity版本的Analysis的package导入,测试apk通过,希望接入G+登录时,因为没有专门给unity的版本,所以直接去google的官网,在安卓工程的build.gradle里添加了

implementation 'com.google.android.gms:play-services-auth:17.0.0'

然后发现这个库和unity那边导出的一堆jar和aar出现了类似于Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core.core-1.0.0.aar) and classes.jar (androidx.core:core:1.0.0)的报错等。

可以通过删除unity导出的对应aar和jar来解决,也可以通过在implementation google的库的时候,exclude掉冲突的部分解决,如下

implementation ('com.google.android.gms:play-services-auth:17.0.0') {
    exclude group: 'androidx.core',module:'core'
    exclude group: 'androidx.annotation',module:'annotation'
    exclude group: 'androidx.arch.core',module:'core-runtime'
    exclude group: 'androidx.asynclayoutinflater',module:'asynclayoutinflater'
    exclude group: 'androidx.arch.core',module:'core-common'
    exclude group: 'androidx.collection',module:'collection'
    exclude group: 'androidx.coordinatorlayout',module:'coordinatorlayout'
    exclude group: 'androidx.cursoradapter',module:'cursoradapter'
    exclude group: 'androidx.documentfile',module:'documentfile'
    exclude group: 'androidx.drawerlayout',module:'drawerlayout'
    exclude group: 'androidx.fragment',module:'fragment'
    exclude group: 'androidx.interpolator',module:'interpolator'
    exclude group: 'androidx.legacy',module:'legacy-support-core-ui'
    exclude group: 'androidx.legacy',module:'legacy-support-core-utils'
    exclude group: 'androidx.lifecycle',module:'lifecycle-viewmodel'
    exclude group: 'androidx.lifecycle',module:'lifecycle-common'
    exclude group: 'androidx.lifecycle',module:'lifecycle-livedata'
    exclude group: 'androidx.loader',module:'loader'
    exclude group: 'com.google.android.gms',module:'play-services-basement'
    exclude group: 'com.google.android.gms',module:'play-services-base'
    exclude group: 'com.google.android.gms',module:'play-services-tasks'
}

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注