ML_Follow
ML_Follow

Reputation: 43

Encountering two errors when building unity for android, firebase SDK

I'm receiving both errors:

Could not create task ':processDebugGoogleServices'.

Cannot create a proxy class for abstract class '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.

Also running ./gradlew :dependencies didn't show anything.

Upvotes: 2

Views: 4679

Answers (3)

SntSdg
SntSdg

Reputation: 36

I had issue with combo Firebase+Unity+gradle. Solved by downgrading gradle.

Unity -> Edit -> Preference -> Gradle to version 6.7.1

It seems that Firebase could not work with newer gradle versions.

Download: Gradle

Upvotes: 0

Shekeela Valamekkil
Shekeela Valamekkil

Reputation: 1

In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services Gradle plugin. Check that you have Google's Maven repository, as well.

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:

apply plugin: 'com.google.gms.google-services'  

Upvotes: 0

Patrick Martin
Patrick Martin

Reputation: 3131

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'. 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). The Firebase SDK for Unity will do this automatically placing this file under 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).

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. 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).

Screenshot of the Project Settings window showing "Custom Main Gradle Template" and "Custom Base Gradle Template" checked

From here, since you mentioned disabling the External Dependency Manager for Unity (EDM4U), you will want to force resolve your Android dependencies. Screenshot showing "Force Resolve" under "Assets/External Dependency Manager/Android Resolver"

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: Screenshot of "Android Resolver Settings" showing the above options checked

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. 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. 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).

If this doesn't help, I'd like to see a more complete error log to try to suss out the actual cause.

Upvotes: 1

Related Questions