ckiro
@ckiro

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Unity&Androidでビルドする際にSDK/Gradle関連のエラーが発生する

解決したいこと

Unity上でOpenXRを使用してQuest2で動作するアプリケーションを制作しており、Android10(APILEVEL29)上で動作することを目指しています。アプリケーションはVR空間上でボタン等を配置しており、それらを操作することが目的ですが詳細は割愛します。

###環境
Windows10 Home 22H2
Unity2022.3.2f1
AndroidStudio 2022.3.1
Android10

###発生している問題
apkファイルとして出力するためにビルドしたところ、

※ユーザー名は伏せていますが、実際はアルファベットのみで構成された文字列です。

Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> 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 :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:mergeReleaseJniLibFolders 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 :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:mergeReleaseJniLibFolders 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 :launcher:collectReleaseDependencies UP-TO-DATE
> Task :launcher:sdkReleaseDependencyData UP-TO-DATE
> Task :launcher:validateSigningRelease UP-TO-DATE
> Task :launcher:writeReleaseAppMetadata UP-TO-DATE
> Task :launcher:writeReleaseSigningConfigVersions UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :unityLibrary:processReleaseManifest UP-TO-DATE
> Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> Task :unityLibrary:extractReleaseAnnotations UP-TO-DATE
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
> Task :unityLibrary:mergeReleaseGeneratedProguardFiles UP-TO-DATE
> Task :unityLibrary:mergeReleaseConsumerProguardFiles UP-TO-DATE
> Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
> Task :unityLibrary:compileReleaseShaders NO-SOURCE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
> Task :unityLibrary:prepareReleaseArtProfile UP-TO-DATE
> Task :unityLibrary:processReleaseJavaRes UP-TO-DATE
> Task :unityLibrary:mergeReleaseJavaResource UP-TO-DATE
> Task :unityLibrary:syncReleaseLibJars UP-TO-DATE
> Task :unityLibrary:writeReleaseAarMetadata UP-TO-DATE
> Task :launcher:mergeReleaseAssets
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :launcher:checkReleaseAarMetadata UP-TO-DATE
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :launcher:mergeReleaseResources UP-TO-DATE
> Task :launcher:mergeReleaseArtProfile UP-TO-DATE
> Task :launcher:compressReleaseAssets
> Task :unityLibrary:bundleReleaseLocalLintAar
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
> Task :unityLibrary:bundleLibCompileToJarRelease UP-TO-DATE
> Task :launcher:processReleaseMainManifest UP-TO-DATE
> Task :launcher:processReleaseManifest UP-TO-DATE
> Task :launcher:processReleaseManifestForPackage UP-TO-DATE
> Task :unityLibrary:bundleLibResRelease UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeToJarRelease UP-TO-DATE
> Task :unityLibrary:createFullJarRelease UP-TO-DATE
> Task :unityLibrary:writeReleaseLintModelMetadata UP-TO-DATE
> Task :unityLibrary:copyReleaseJniLibsProjectOnly UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeToDirRelease UP-TO-DATE
> Task :launcher:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:stripReleaseDebugSymbols
> Task :launcher:mergeReleaseJavaResource UP-TO-DATE
> Task :launcher:extractReleaseNativeSymbolTables
> Task :launcher:processReleaseResources FAILED
> Task :launcher:mergeReleaseNativeDebugMetadata
63 actionable tasks: 8 executed, 55 up-to-date

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR:C:\Users\ユーザー名\UnityXR\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build\intermediates\packaged_manifests\release\AndroidManifest.xml:39: AAPT: error: unexpected element <use-feature> found in <manifest>.
         

* 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

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\Hub\Editor\2022.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2022.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.2.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Environment Variables:
__PSLockDownPolicy = 0
USERDOMAIN = DESKTOP-ABK928H
ProgramFiles = C:\Program Files
TMP = C:\Users\ユーザー名\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 8e0c
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_13648_SACNCGMAQFSYVPJV
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
USERPROFILE = C:\Users\ユーザー名
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\WINDOWS\system32\cmd.exe
LAUNCH_DARKLY_CLIENT_TOKEN = 60a7e30fafc7e60e33446283
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC = C:\Users\Public
SystemRoot = C:\WINDOWS
HEAP_CLIENT_TOKEN = 1717415662
NUMBER_OF_PROCESSORS = 8
AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21
WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
DEBUG_ENV_VAR = UnityHub
ProgramW6432 = C:\Program Files
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
HOMEDRIVE = C:
TEMP = C:\Users\ユーザー名\AppData\Local\Temp
Path = C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;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\130\Tools\Binn\;C:\Program Files\dotnet\;C:\Graphviz\bin;C:\Users\ユーザー名\AppData\Local\Programs\Python\Python311\Scripts;;C:\Users\ユーザー名\.dotnet\tools;C:\Users\ユーザー名\AppData\Local\Programs\Microsoft VS Code\bin
USERNAME = ユーザー名
COMPUTERNAME = DESKTOP-ABK928H
USERDOMAIN_ROAMINGPROFILE = DESKTOP-ABK928H
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
SystemDrive = C:
ALLUSERSPROFILE = C:\ProgramData
SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017
HEAP_CLIENT_TOKEN_STAGING = 3786794399
FPS_BROWSER_USER_PROFILE_STRING = Default
windir = C:\WINDOWS
ZES_ENABLE_SYSMAN = 1
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\ユーザー名\AppData\Roaming
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
NVIDIAWHITELISTED = 0x01
SESSIONNAME = Console
LOGONSERVER = \\DESKTOP-ABK928H
LOCALAPPDATA = C:\Users\ユーザー名\AppData\Local
HOMEPATH = \Users\ユーザー名
LAUNCH_DARKLY_CLIENT_TOKEN_STAGING = 60a7e30fafc7e60e33446282
SHIM_MCCOMPAT = 0x810000001
OneDrive = C:\Users\ユーザー名\OneDrive
ProgramData = C:\ProgramData
ORIGINAL_XDG_CURRENT_DESKTOP = undefined


stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR:C:\Users\ユーザー名\UnityXR\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\build\intermediates\packaged_manifests\release\AndroidManifest.xml:39: AAPT: error: unexpected element <use-feature> found in <manifest>.
         

* 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[
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
> 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 :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:mergeReleaseJniLibFolders 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 :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:mergeReleaseJniLibFolders 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 :launcher:collectReleaseDependencies UP-TO-DATE
> Task :launcher:sdkReleaseDependencyData UP-TO-DATE
> Task :launcher:validateSigningRelease UP-TO-DATE
> Task :launcher:writeReleaseAppMetadata UP-TO-DATE
> Task :launcher:writeReleaseSigningConfigVersions UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :unityLibrary:processReleaseManifest UP-TO-DATE
> Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> Task :unityLibrary:extractReleaseAnnotations UP-TO-DATE
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
> Task :unityLibrary:mergeReleaseGeneratedProguardFiles UP-TO-DATE
> Task :unityLibrary:mergeReleaseConsumerProguardFiles UP-TO-DATE
> Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
> Task :unityLibrary:compileReleaseShaders NO-SOURCE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
> Task :unityLibrary:prepareReleaseArtProfile UP-TO-DATE
> Task :unityLibrary:processReleaseJavaRes UP-TO-DATE
> Task :unityLibrary:mergeReleaseJavaResource UP-TO-DATE
> Task :unityLibrary:syncReleaseLibJars UP-TO-DATE
> Task :unityLibrary:writeReleaseAarMetadata UP-TO-DATE
> Task :launcher:mergeReleaseAssets
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :launcher:checkReleaseAarMetadata UP-TO-DATE
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :launcher:mergeReleaseResources UP-TO-DATE
> Task :launcher:mergeReleaseArtProfile UP-TO-DATE
> Task :launcher:compressReleaseAssets
> Task :unityLibrary:bundleReleaseLocalLintAar
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
> Task :unityLibrary:bundleLibCompileToJarRelease UP-TO-DATE
> Task :launcher:processReleaseMainManifest UP-TO-DATE
> Task :launcher:processReleaseManifest UP-TO-DATE
> Task :launcher:processReleaseManifestForPackage UP-TO-DATE
> Task :unityLibrary:bundleLibResRelease UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeToJarRelease UP-TO-DATE
> Task :unityLibrary:createFullJarRelease UP-TO-DATE
> Task :unityLibrary:writeReleaseLintModelMetadata UP-TO-DATE
> Task :unityLibrary:copyReleaseJniLibsProjectOnly UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeToDirRelease UP-TO-DATE
> Task :launcher:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:stripReleaseDebugSymbols
> Task :launcher:mergeReleaseJavaResource UP-TO-DATE
> Task :launcher:extractReleaseNativeSymbolTables
> Task :launcher:processReleaseResources FAILED
> Task :launcher:mergeReleaseNativeDebugMetadata
63 actionable tasks: 8 executed, 55 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2a152c15da574a70b6653d9f1dbcd106>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2a152c15da574a70b6653d9f1dbcd106>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2a152c15da574a70b6653d9f1dbcd106>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <2a152c15da574a70b6653d9f1dbcd106>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2a152c15da574a70b6653d9f1dbcd106>: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.Action`1[T] progress) (at <2a152c15da574a70b6653d9f1dbcd106>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2a152c15da574a70b6653d9f1dbcd106>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2a152c15da574a70b6653d9f1dbcd106>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Build completed with a result of 'Failed' in 1226 seconds (1225787 ms)
3 errors
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

自分で試したこと

・Android29をCMDからインストール
・Android StudioからSDKをインストール
・別のWindowsPC上で再構築
・Unity,PC自体の再起動
・Unityのバージョンを2021.3.29fへ落とす
・Gradleをダウンロード後、パスを通す
・PreferenceからJDK,SDK,Gradleのパスのチェックを外してから再起動後チェックを付ける
・別の方式でビルド(別プロジェクトのWindows出力は成功、android出力は失敗)

ハードウェアやUnity上のオブジェクトではなくSDK,JDK.Gradle関連のエラーだと推察されますが、具体的な解決方法が見つかっていない状態です。
よろしくお願いいたします。

1

1Answer

① Unity,UnityHUB,SDK,Gradleをすべて削除
② Unity,UnityHUBを再インストール
③ 新プロジェクトをUnity2021で作成し起動
④ 必要なpackageをインポート
⑤ 元プロジェクトからオブジェクト・プレファブ・シーン・C#スクリプトをインポート
⑥ 外れているプレファブ等を再度アタッチ・微調整

以上の工程を経たところ、正常に作用しました。
Unity以外でAndroid開発をしない場合はこれが最終手段になると思います。

Unity2022で作業していたこと、プロジェクトが何らかの事情で破損した可能性が考えられますが最後まで原因は特定できませんでした。

0Like

Your answer might help someone💌