- Home /
Gradle failed to fetch dependencies for Firebase and Google Play Service
I got an error something like this, tried several methods still it couldn't resolve.
LOG
Gradle failed to fetch dependencies.
Failed to run 'C:\Unity Games\DownHill Republic\Temp\PlayServicesResolverGradle\gradlew.bat --no-daemon -b "C:\Unity Games\DownHill Republic\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle" "-PANDROID_HOME=C:/Program Files/Unity/Hub/Editor/2019.4.13f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK" "-PTARGET_DIR=C:\Unity Games\DownHill Republic\Assets\Plugins\Android" "-PMAVEN_REPOS=file:///C:/Unity%20Games/DownHill%20Republic/Assets/Firebase/m2repository;file:///C:/Unity%20Games/DownHill%20Republic/Assets/GooglePlayGames/Editor/m2repository" "-PPACKAGES_TO_COPY=com.google.firebase:firebase-common:20.0.0;com.google.firebase:firebase-analytics:19.0.0;com.google.android.gms:play-services-base:17.6.0;com.google.firebase:firebase-app-unity:8.4.0;com.google.firebase:firebase-auth:21.0.1;com.google.firebase:firebase-auth-unity:8.4.0;com.google.firebase:firebase-messaging:22.0.0;com.google.firebase:firebase-iid:21.1.0;com.google.firebase:firebase-messaging-unity:8.4.0;com.google.firebase:firebase-storage:20.0.0;com.google.firebase:firebase-storage-unity:8.4.0;com.google.games:gpgs-plugin-support:0.10.12" "-PUSE_JETIFIER=0" "-PDATA_BINDING_VERSION=3.4.0"'
stdout:
stderr:
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type DefaultModuleRegistry using GlobalScopeServices.createModuleRegistry().
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
exit code: 1
[Log] DependOn - group: com.google.firebase artifact: firebase-common version: 20.0.0 classifier: null packageIds: repositories:
[Log] (4) DependOn - group: com.google.firebase artifact: firebase-analytics version: 19.0.0 classifier: null packageIds: repositories:
[Log] DependOn - group: com.google.android.gms artifact: play-services-base version: 17.6.0 classifier: null packageIds: repositories:
[Log] DependOn - group: com.google.firebase artifact: firebase-auth version: 21.0.1 classifier: null packageIds: repositories:
[Log] DependOn - group: com.google.firebase artifact: firebase-messaging version: 22.0.0 classifier: null packageIds: repositories:
[Log] DependOn - group: com.google.firebase artifact: firebase-iid version: 21.1.0 classifier: null packageIds: repositories:
[Log] DependOn - group: com.google.firebase artifact: firebase-storage version: 20.0.0 classifier: null packageIds: repositories:
[Log] Reading Android dependency XML file Assets/GooglePlayGames/Editor/GooglePlayGamesPluginDependencies.xml
[Log] DependOn - group: com.google.games artifact: gpgs-plugin-support version: 0.10.12 classifier: null packageIds: repositories: Assets/GooglePlayGames/Editor/m2repository
Resolution failed
Failed to fetch the following dependencies:
com.google.firebase:firebase-common:20.0.0
com.google.firebase:firebase-analytics:19.0.0
com.google.android.gms:play-services-base:17.6.0
com.google.firebase:firebase-app-unity:8.4.0
com.google.firebase:firebase-auth:21.0.1
com.google.firebase:firebase-auth-unity:8.4.0
com.google.firebase:firebase-messaging:22.0.0
com.google.firebase:firebase-iid:21.1.0
com.google.firebase:firebase-messaging-unity:8.4.0
com.google.firebase:firebase-storage:20.0.0
com.google.firebase:firebase-storage-unity:8.4.0
com.google.games:gpgs-plugin-support:0.10.12
[Log] Missing Android component com.google.firebase:firebase-common:20.0.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-analytics:19.0.0 (Android SDK Packages: )
[Log] Missing Android component com.google.android.gms:play-services-base:17.6.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-app-unity:8.4.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-auth:21.0.1 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-auth-unity:8.4.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-messaging:22.0.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-iid:21.1.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-messaging-unity:8.4.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-storage:20.0.0 (Android SDK Packages: )
[Log] Missing Android component com.google.firebase:firebase-storage-unity:8.4.0 (Android SDK Packages: )
[Log] Missing Android component com.google.games:gpgs-plugin-support:0.10.12 (Android SDK Packages: )
Any way to solve this?
Answer by ALIENPANDA · Oct 30, 2021 at 12:37 PM
In the Unity Editor, open your project and go to Project Settings > Player > Publish Settings > Custom Main Gradle Template and ensure the Custom Main Gradle Template checkbox is enabled.
Then, go to the Project tab and navigate to Assets > PlayServicesResolver > Android Resolver > Force Resolve.
Now try to build the project. (With these settings, Android dependencies will not be included directly in the project anymore)
This will resolve all the dependencies. In case if you have trouble while taking build (Gradel Build). Go to Project Settings > Player > Publishing Settings and select the Custom Gradle Properties Template checkbox. Then Navigate to the path below the checkbox and add these two lines to the end of the file:
android.useAndroidX=true
android.enableJetifier=true
And then take a build. hope it works.
Your answer
Follow this Question
Related Questions
Unsupported major.minor version 52.0 - Android Build Error 2 Answers
Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define 0 Answers
i try to build to andriod but i keep getting this error what can i do about it? 0 Answers
Importing object type from .so lib 1 Answer
Android build crashes on start up. 2 Answers