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'
}
前阵子升级fb sdk,因为Unity版本过老,facebook unity sdk已经不再支持,只能重新接入安卓版本。更新的时候找到了一个更简单有效的方式,在Unity的Assets目录找个地方塞个Dependencies.xml文件,注意该文件必须放在Editor文件夹下,格式类似如下
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<androidPackage spec="com.facebook.android:facebook-android-sdk:16.0.0" />
</androidPackages>
</dependencies>
然后在Android Resolver里Resolve一下依赖,如果有个别aar版本多版本都存在,可以先Delete Resolved Libraries,再Resolve即可。