Unity发布android Pico报错——CommandInvokationFailure: Gradle build failed踩坑记录

〇、病情介绍

在Unity中配置Pico的插件后,发布成PICO的apk时,报错。显示的是gradle出错:CommandInvokationFailure: Gradle build failed

开发环境:

(1)Unity 环境 = Unity2021.3.44

(2)PICO 头盔 = PICO 4 Ultra

(3)PICO 插件 = PICO Unity Integration SDK-3.0.5

一、治病过程

  • 1、怀疑过项目目录包含了中文,改正后继续报错

  • 2、增加了android sdk包的数量:以前只有33、34、35,添加了更多的,还是报错。

  • 3、改gradle build配置文件中的版本号,还是报错

    ...

    折腾了一天,无果

  • 4、第二天,重新梳理报错文档,发现报错信息说:

    编译器找不到gradle所需要的资源代码,它分别找过三个地方:【Gradle Central Plugin Repository】、【Google】、【MavenRepo】,都没有找到。

csharp 复制代码
* What went wrong:
Plugin [id: 'com.android.application', version: '7.4.2', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:7.4.2')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    Google
    MavenRepo

怀疑是联网的问题,估计是被墙了。

  • 5、猜测病症:应该是连不上VPN,被欓妈妈关怀了(改用手机热点连接,而不是校园网)。于是换网络,还是不行。

  • 6、于是在Unity Hub里面,卸载Unity2021.3.44,然后重新安装Unity2021.3.44。安装前,弃用校园网,改用手机流量,确保VPN打开,而且全局代理,同时勾选android的选项,然后重新安装。

  • 7、测试发布:先发布普通的Android,OK,然后再加入pico的sdk继续发布Android Pico,显示OK

  • 8、总结:发布的时候,需要在线更新一些包或者插件,因为网络不通,造成失败,而且一些错误的东西被缓存了。卸载后重装,然后联网Build。

二、附录:详细错误信息

csharp 复制代码
CommandInvokationFailure: Gradle build failed. 
E:\UnityInstall\2021.3.44f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "E:\UnityInstall\2021.3.44f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.5.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Environment Variables:
USERDOMAIN = DZJ
ProgramFiles = C:\Program Files
TMP = C:\Users\georg\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 7100
OneDriveConsumer = C:\Users\georg\OneDrive
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_23468_CXPEPFSPXDTTGJPG
PROCESSOR_IDENTIFIER = AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
ProgramW6432 = C:\Program Files
USERPROFILE = C:\Users\georg
JAVA_HOME = E:\UnityInstall\2021.3.44f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\Windows\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ANDROID_NDK_ROOT = E:\UnityInstall\2021.3.44f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
USERNAME = georg
NUMBER_OF_PROCESSORS = 6
TEMP = C:\Users\georg\AppData\Local\Temp
Path = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;E:\Program Files (x86)\Git\cmd;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\georg\AppData\Local\Microsoft\WindowsApps;C:\Users\georg\.dotnet\tools;E:\Program Files (x86)\Fiddler
COMPUTERNAME = DZJ
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
ALLUSERSPROFILE = C:\ProgramData
SystemDrive = C:
EFC_30628 = 1
windir = C:\Windows
HOMEPATH = \Users\georg
PUBLIC = C:\Users\Public
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\georg\AppData\Roaming
OneDrive = C:\Users\georg\OneDrive
PROCESSOR_LEVEL = 23
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SystemRoot = C:\Windows
SESSIONNAME = Console
LOGONSERVER = \\DZJ
LOCALAPPDATA = C:\Users\georg\AppData\Local
HOMEDRIVE = C:
USERDOMAIN_ROAMINGPROFILE = DZJ
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined


stderr[

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\��Ŀ�ļ�����\28������ѧԺ-����-����\demo\My project\Library\Bee\Android\Prj\IL2CPP\Gradle\build.gradle' line: 6

* What went wrong:
Plugin [id: 'com.android.application', version: '7.4.2', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:7.4.2')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    Google
    MavenRepo

* 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

BUILD FAILED in 37s
]
stdout[

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <a08d9c3a168a4fa582db19b6dbf392b3>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <1518627dacca44efa32edd45bc720c48>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
相关推荐
后端码匠4 小时前
MySQL 8.0安装(压缩包方式)
android·mysql·adb
敲代码的 蜡笔小新4 小时前
【行为型之中介者模式】游戏开发实战——Unity复杂系统协调与通信架构的核心秘诀
unity·设计模式·c#·中介者模式
梓仁沐白5 小时前
Android清单文件
android
敲代码的 蜡笔小新7 小时前
【行为型之解释器模式】游戏开发实战——Unity动态公式解析与脚本系统的架构奥秘
unity·设计模式·游戏引擎·解释器模式
董可伦7 小时前
Dinky 安装部署并配置提交 Flink Yarn 任务
android·adb·flink
每次的天空8 小时前
Android学习总结之Glide自定义三级缓存(面试篇)
android·学习·glide
恋猫de小郭8 小时前
如何查看项目是否支持最新 Android 16K Page Size 一文汇总
android·开发语言·javascript·kotlin
flying robot10 小时前
小结:Android系统架构
android·系统架构
xiaogai_gai10 小时前
有效的聚水潭数据集成到MySQL案例
android·数据库·mysql
鹅鹅鹅呢11 小时前
mysql 登录报错:ERROR 1045(28000):Access denied for user ‘root‘@‘localhost‘ (using password Yes)
android·数据库·mysql