Gradle 无法获取 Unity Mediation、Firebase 和 Google Play 服务的依赖项

Gradle failed to fetch dependencies for Unity Mediation, Firebase, and Google Play Service

我无法强制解决这个问题。直到几天前它工作正常。我假设在从 Unity Mediation 安装一个包后,这一切都是问题。之后,我删除了那个包,但这个错误仍然没有解决。

[Log] Reading Android dependency XML file Assets/Editor/MediationAdapterDependencies.xml
[Log] DependOn - group: com.unity3d.mediation artifact: mediation-sdk version: [0.2,0.3[ classifier: null packageIds:  repositories:
[Log] DependOn - group: com.unity3d.mediation artifact: admob-adapter version: [0.2,0.3[ classifier: null packageIds:  repositories:
[Log] DependOn - group: com.unity3d.mediation artifact: unityads-adapter version: [0.2,0.3[ classifier: null packageIds:  repositories:
[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.unity3d.mediation:mediation-sdk:[0.2,0.3[
com.unity3d.mediation:admob-adapter:[0.2,0.3[
com.unity3d.mediation:unityads-adapter:[0.2,0.3[
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.unity3d.mediation:mediation-sdk:[0.2,0.3[ (Android SDK Packages: )
[Log] Missing Android component com.unity3d.mediation:admob-adapter:[0.2,0.3[ (Android SDK Packages: )
[Log] Missing Android component com.unity3d.mediation:unityads-adapter:[0.2,0.3[ (Android SDK Packages: )
[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: )

我什至试图再次重新导入所有这些包。尽管如此,问题仍然存在。

  1. 在 Unity 编辑器中,打开您的项目并转到“项目设置”>“播放器”>“发布设置”>“自定义主要 Gradle 模板”并确保启用“自定义主要 Gradle 模板”复选框。
  2. 然后,转到“项目”选项卡并导航到“资产”>“PlayServicesResolver”>“Android解析器”>“强制解析”。
  3. 现在尝试构建项目。 (使用这些设置,Android 依赖项将不再直接包含在项目中)

这将解决所有依赖项。如果您在构建 (Gradel Build) 时遇到问题。转到项目设置 > 播放器 > 发布设置和 select 自定义 Gradle 属性模板复选框。然后 导航到复选框下方的路径并将这两行添加到文件末尾:

android.useAndroidX=true
android.enableJetifier=true

然后进行构建。希望有用。