[英]Encountering two errors when building unity for android, firebase SDK
I'm receiving both errors:我收到两个错误:
Could not create task ':processDebugGoogleServices'.无法创建任务“:processDebugGoogleServices”。
Cannot create a proxy class for abstract class 'GoogleServicesTask'.无法为抽象类“GoogleServicesTask”创建代理类。
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.3.4'
**BUILD_SCRIPT_DEPS**}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
// Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each {
ext {
it.setProperty("android.useAndroidX", true)
it.setProperty("android.enableJetifier", true)
}
}
([rootProject] + (rootProject.subprojects as List)).each { project ->
project.repositories {
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
maven {
url "https://maven.google.com"
}
maven {
url "https://deltadna.bintray.com/android" // Assets/DeltaDNA/Editor/Android/Dependencies.xml:8
}
maven {
url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository") // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22
}
mavenLocal()
jcenter()
mavenCentral()
}
}
// Android Resolver Repos End
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Android Resolver Dependencies Start
implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.deltadna.android:deltadna-sdk-notifications:4.10.0' // Assets/DeltaDNA/Editor/Android/Dependencies.xml:8
implementation ('com.facebook.android:facebook-applinks:[5,6)') {
exclude group: 'com.google.zxing'
}// Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6
implementation ('com.facebook.android:facebook-core:[5,6)') {
exclude group: 'com.google.zxing'
}// Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:5
implementation ('com.facebook.android:facebook-login:[5,6)') {
exclude group: 'com.google.zxing'
} // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:7
implementation ('com.facebook.android:facebook-share:[5,6)') {
exclude group: 'com.google.zxing'
} // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:8
implementation 'com.google.android.gms:play-services-base:17.4.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.firebase:firebase-analytics:17.6.0' // Assets/Firebase/Editor/AppDependencies.xml:15
implementation 'com.google.firebase:firebase-analytics-unity:6.16.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
implementation 'com.google.firebase:firebase-app-unity:6.16.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-common:19.3.1' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:4
// Android Resolver Dependencies End
// ** revenuecat **
implementation ('com.revenuecat.purchases:purchases-hybrid-common:1.2.0') {
exclude group: 'com.android.billingclient', module: 'billing'
}
implementation 'com.android.support:multidex:1.0.3'
**DEPS**}
// Android Resolver Exclusions Start
android {
packagingOptions {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}
}
// Android Resolver Exclusions End
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
multiDexEnabled true
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**SIGN**
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
useProguard **PROGUARD_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
useProguard **PROGUARD_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
}
}**PACKAGING_OPTIONS****SPLITS**
**BUILT_APK_LOCATION**
**EXTERNAL_SOURCES**
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
}**SPLITS_VERSION_CODE****REPOSITORIES****SOURCE_BUILD_SETUP**
I saw several threads that said i should remove apply plugin: 'com.google.gms.google-services'
or to update classpath 'com.android.tools.build:gradle:3.4.0'
to classpath 'com.android.tools.build:gradle:4.0.0'
but that didn't do it for me and only caused more problems.我看到几个线程说我应该删除apply plugin: 'com.google.gms.google-services'
或将classpath 'com.android.tools.build:gradle:3.4.0'
更新为classpath 'com.android.tools.build:gradle:4.0.0'
但这对我没有用,只会引起更多问题。
Also running ./gradlew :dependencies
didn't show anything.还运行./gradlew :dependencies
没有显示任何内容。
It's difficult to exactly say what's happening, but I have a few suggestions that should work.很难准确说出正在发生的事情,但我有一些应该可行的建议。
First, get rid of classpath 'com.google.gms:google-services:4.3.4'
under dependencies
and apply plugin: 'com.google.gms.google-services'
.首先,摆脱dependencies
下的classpath 'com.google.gms:google-services:4.3.4'
并apply plugin: 'com.google.gms.google-services'
。 The reason is that the purpose of this is to read a google-services.json
file in your project directory and generate a res/values/google-services.xml
file (more information here ).原因是这样做的目的是读取项目目录中的google-services.json
文件并生成res/values/google-services.xml
文件(更多信息请点击此处)。 The Firebase SDK for Unity will do this automatically placing this file under Assets/Plugins/FirebaseApp.androidlib/res/values/google-services.xml
. Firebase SDK for Unity 会自动将此文件放置在Assets/Plugins/FirebaseApp.androidlib/res/values/google-services.xml
。 Anything in a Plugins/*.androidlib
file is now automatically pulled into the Android project, rendering this step redundant (and often causing errors both on the Unity and Android side). Plugins/*.androidlib
文件中的任何内容现在都会自动拉入 Android 项目,使这一步变得多余(并且经常在 Unity 和 Android 端导致错误)。
Since you've used Unity to generate a mainTemplate.gradle
file and you're using a newer version of Unity (2019.3 and above), you'll also need to generate a gradleTemplate.properties
file.由于您已使用 Unity 生成mainTemplate.gradle
文件,并且您使用的是较新版本的 Unity(2019.3 及更高版本),因此您还需要生成gradleTemplate.properties
文件。 This way we can enable AndroidX (the replacement for the Android Support libraries now used by Firebase) and enable Jetifier (which will upgrade Google Support dependencies that it looks like Facebook is pulling in).通过这种方式,我们可以启用 AndroidX(替代 Firebase 现在使用的 Android 支持库)并启用 Jetifier(这将升级看起来 Facebook 正在引入的 Google 支持依赖项)。
From here, since you mentioned disabling the External Dependency Manager for Unity (EDM4U), you will want to force resolve your Android dependencies.从这里开始,由于您提到禁用 Unity 的外部依赖项管理器 (EDM4U),您将需要强制解决您的 Android 依赖项。
You will want to have "Patch mainTemplate.gradle", "Use Jetifier.", and "Patch gradleTemplate.properties" all checked in your Android Resolver Settings for this to work:您需要在 Android Resolver Settings 中检查“Patch mainTemplate.gradle”、“Use Jetifier.”和“Patch gradleTemplate.properties”以使其正常工作:
If you're running into issues or you don't want to run EDM4U, I'm trying to do is add android.useAndroidX=true
and android.enableJetifier=true
to gradleTemplate.properties
.如果您遇到问题或不想运行 EDM4U,我正在尝试将android.useAndroidX=true
和android.enableJetifier=true
到gradleTemplate.properties
。 For my own game, this file now looks like:对于我自己的游戏,这个文件现在看起来像:
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
**ADDITIONAL_PROPERTIES**
android.useAndroidX=true
android.enableJetifier=true
To recap, at this point you should have removed the play services plugin and enabled AndroidX and Jetifier support.回顾一下,此时您应该已经删除了播放服务插件并启用了 AndroidX 和 Jetifier 支持。 You should be able to either build from Unity or export a gradle project and build from the command line (this latter is always a challenge in Unity since they opt to not use gradlew, so you may run into incompatibility with your system gradle).您应该能够从 Unity 构建或导出 gradle 项目并从命令行构建(后者在 Unity 中始终是一个挑战,因为他们选择不使用 gradlew,因此您可能会遇到与系统 gradle 不兼容的问题)。
If this doesn't help, I'd like to see a more complete error log to try to suss out the actual cause.如果这没有帮助,我想查看更完整的错误日志以尝试找出实际原因。
In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services Gradle plugin.在您的根级(项目级)Gradle 文件 (build.gradle) 中,添加规则以包含 Google Services Gradle 插件。 Check that you have Google's Maven repository, as well.检查您是否也拥有 Google 的 Maven 存储库。
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.android.tools.build:gradle:3.3.1'
}
And then:接着:
In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin:在您的模块(应用级)Gradle 文件(通常是 app/build.gradle)中,应用 Google Services Gradle 插件:
apply plugin: 'com.google.gms.google-services'
I had issue with combo Firebase
+ Unity
+ gradle
.我遇到了Firebase
+ Unity
+ gradle
组合的问题。 Solved by downgrading gradle
.通过降级gradle
解决。
Unity
->Edit
->Preference
->Gradle
to version6.7.1
Unity
->Edit
->Preference
->Gradle
to version6.7.1
It seems that Firebase
could not work with newer gradle
versions. Firebase
似乎无法与较新的gradle
版本一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.