You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity Android构建报错求助:Gradle依赖失败与SDK管理器问题

解决Unity中Google Play Services Resolver的两个核心错误

Hey Matt, let's work through these two frustrating issues with your Unity Android project—they’re likely tied to outdated resolver tools or misconfigured SDK settings. Here’s how to fix each one step by step:

错误1:Gradle failed to fetch dependencies(输入字符串"0-alpha1")

This error pops up because the Play Services Resolver is trying to pull an unstable alpha version of a dependency, which breaks the Gradle evaluation. Here’s how to fix it:

  • Update the External Dependency Manager (formerly Play Services Resolver)
    Open Unity’s Window > Package Manager, search for "External Dependency Manager for Unity" (it replaced the old Play Services Resolver), and install/update it to the latest stable version. If it’s not in the Package Manager, grab it from the Unity Asset Store—this is the most common fix for version-related parsing errors.

  • Lock dependency versions to stable releases
    Go to Window > Google > Play Services Resolver > Android Resolver > Settings. In the "Dependency Version" section, replace the + wildcard in your packages with specific stable versions. For example:

    • com.google.android.gms:play-services-gcm:17.0.0
    • com.google.android.gms:play-services-location:21.0.1
    • com.android.support:customtabs:28.0.0
    • com.android.support:support-v4:28.0.0
      This prevents the resolver from pulling untested alpha builds like "0-alpha1".
  • Clear cached Gradle files
    Delete the Temp/PlayServicesResolverGradle folder in your Unity project, then clear your system Gradle cache (usually located at C:\Users\<YourUsername>\.gradle\caches). Restart Unity and let the resolver re-download dependencies fresh.

错误2:Unable to find Android SDK manager tool & missing M2 repositories

This issue happens when Unity can’t locate the SDK manager tool, or the required Google/Android M2 repositories aren’t installed properly. Try these fixes:

  • Verify Unity’s SDK path configuration
    Open Edit > Preferences > External Tools in Unity. Double-check that the Android SDK path points to your correct SDK directory (e.g., F:/Programs/AndroidSDK)—make sure there are no spaces or special characters in the path, which can break tool detection.

  • Manually install missing repositories via Android Studio
    Open Android Studio, go to Tools > SDK Manager, switch to the SDK Tools tab, and check "Show Package Details". Under the Extras section, find and install:

    • Google Repository (latest stable version)
    • Android Repository (latest stable version)
      Once installed, go back to Unity and run Window > Google > Play Services Resolver > Android Resolver > Resolve to re-detect the repositories.
  • Fix SDK Manager tool accessibility
    Ensure you have the Command-line Tools installed in Android Studio’s SDK Manager (under SDK Tools). Add the cmdline-tools/bin folder from your SDK directory (e.g., F:/Programs/AndroidSDK/cmdline-tools/latest/bin) to your system’s PATH environment variable. This lets Unity find the sdkmanager command properly.

  • Reset the resolver’s state
    Go to Window > Google > Play Services Resolver > Android Resolver > Reset Resolver to clear any cached SDK detection data, then re-run the resolve process.

补充:关于游戏运行缓慢的问题

While you think it’s unrelated to the errors, unresolved dependency issues can sometimes cause hidden overhead (like failed lazy loading or fallback logic). Once you fix the two core errors, use Unity’s Profiler (Window > Analysis > Profiler) to check for performance bottlenecks—things like excessive draw calls, unoptimized textures, or inefficient script logic are common culprits for slow Android builds.

内容的提问来源于stack exchange,提问作者MOrlando616

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:57:35