Unity,如何修复Android构建时的Gradle错误?

muk1a3rh  于 2023-06-23  发布在  Android
关注(0)|答案(1)|浏览(406)

我正在Unity中创建一个非常简单的项目,到目前为止,我添加的只是一些UI元素。我使用的是v2022.3.0,昨天创建了一个新项目,所以这个项目仍然非常“香草”。
我将构建目标切换到Android并尝试构建我的项目,但我得到了一系列错误。Google Pixel 6手机
当我尝试构建项目时,我得到了以下内容:

> Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could
> not be reused, use --status for details Exception while marshalling
> C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\32.0.0\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-31\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-32\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\32.0.0\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-31\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-32\package.xml.
> Probably the SDK is read-only Exception while marshalling C:\Program
> Files\Unity\Hub\Editor\2022.3.0f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
> > Task :launcher:preBuild UP-TO-DATE
> > Task :unityLibrary:preBuild UP-TO-DATE
> > Task :launcher:preReleaseBuild UP-TO-DATE
> > Task :unityLibrary:preReleaseBuild UP-TO-DATE
> > Task :unityLibrary:compileReleaseAidl NO-SOURCE
> > Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE
> > Task :launcher:generateReleaseBuildConfig UP-TO-DATE
> > Task :launcher:compileReleaseAidl NO-SOURCE
> > Task :launcher:javaPreCompileRelease UP-TO-DATE
> > Task :launcher:generateReleaseResValues UP-TO-DATE
> > Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
> > Task :launcher:extractDeepLinksRelease UP-TO-DATE
> > Task :launcher:extractProguardFiles UP-TO-DATE
> > Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
> > Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
> > Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE
> > Task :unityLibrary:copyReleaseJniLibsProjectAndLocalJars UP-TO-DATE
> > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> > Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
> > Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> > Task :unityLibrary:generateReleaseResources UP-TO-DATE
> > Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
> > Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
> > Task :launcher:mergeExtDexRelease UP-TO-DATE
> > Task :unityLibrary:packageReleaseResources UP-TO-DATE
> > Task :launcher:mergeReleaseShaders UP-TO-DATE
> > Task :launcher:compileReleaseShaders NO-SOURCE
> > Task :launcher:generateReleaseAssets UP-TO-DATE
> > Task :launcher:processReleaseJavaRes NO-SOURCE
> > Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> > Task :unityLibrary:processReleaseManifest UP-TO-DATE
> > Task :launcher:collectReleaseDependencies UP-TO-DATE
> > Task :launcher:sdkReleaseDependencyData UP-TO-DATE
> > Task :launcher:validateSigningRelease UP-TO-DATE
> > Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> > Task :launcher:writeReleaseAppMetadata UP-TO-DATE
> > Task :launcher:writeReleaseSigningConfigVersions UP-TO-DATE
> > Task :unityLibrary:extractReleaseAnnotations UP-TO-DATE
> > Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
> 
> > Task :unityLibrary:compileReleaseJavaWithJavac FAILED 29 actionable tasks: 1 executed, 28 up-to-date
> 
> UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

编辑:更新-所以,我尝试使用2D URP模板构建一个新项目。内置于Android,运行良好。
然后,我使用2D移动的模板创建了一个新项目。我得到了构建错误!
在我最初的项目中,我所做的是从2D URP模板开始,然后使用包管理器添加“移动的”包。
我还应该注意,我得到一个错误,我没有选择一个自适应性能提供程序。所以我进入项目设置,选择了三星提供商(我有一部谷歌手机,但三星是唯一列出的)。在选择三星选项和一些文件加载后,我然后看到一个“Android”提供商也显示,但是,试图选择它失败。它说它不适用于这个版本的编辑器。:(
我仍然迷路了,不能让它建立,除非我删除移动的包,但因为我的目标是我的游戏手机,我假设我会想要那些...

cwtwac6a

cwtwac6a1#

当你的Android构建失败时,你可以做很多不同的事情来修复它。

  • 首先,您可以尝试将目标和最低API级别设置得更高(在发布下的播放器设置中)
  • 您也可以尝试解决或删除您的移动的依赖项,它在资产/移动依赖项解决器/Android解决器/解决或强制解决或删除已解决的库.
  • 你可以尝试的另一件事是,只是删除整个库文件夹。
  • 也有一件事,帮助了我,但只会影响你,如果你使用旧的
    中介包,因为Unity为LevelPlay做了一个新的,所以只需删除旧的包并安装新的。但你必须改变你的广告脚本。
    希望这有帮助:)

相关问题