Unity引入Firebase报错

Unity在引入最新版本Firebase发现报错:

Could not determine the dependencies of task ':launcher:lintVitalRelease'.
> This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
The following AndroidX dependencies are detected: androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0,

大致意思是项目依赖了AndroidX,但是android.useAndroidX没有enabled

解决方案:

BuildSettings->Player->Publishing Settings 勾选Custom Gradle Properties Template。之后unity会自动生模板配置 Assets/Plugins/Android/gradleTemplate.properties
在properties文件中添加以下两行:

android.useAndroidX=true
android.enableJetifier=true

修改之后:

org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
unityStreamingAssets=**STREAMING_ASSETS**
android.useAndroidX=true
android.enableJetifier=true
**ADDITIONAL_PROPERTIES**

问题解决~