将统一游戏导出为 android APK 问题
Posted
技术标签:
【中文标题】将统一游戏导出为 android APK 问题【英文标题】:exporting unity game as android APK issue 【发布时间】:2021-12-07 17:51:06 【问题描述】:我目前正在将我的游戏导出为 APK,但是我遇到了很多对我来说似乎有点模糊的错误。
我正在使用 API 的最高设置,并且我还要确保输入密钥库密码。
我遇到了 3 个错误,我将在下面的代码块中列出这些错误。
有人可以帮忙吗?
> Configure project :launcher
WARNING: The option 'android.enableR8' is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:packageReleaseRenderscript NO-SOURCE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :launcher:mainApkListPersistenceRelease UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseResValues
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseResources
> Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :launcher:prepareLintJar UP-TO-DATE
> Task :launcher:mergeReleaseShaders UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
> Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:packageReleaseResources
> Task :launcher:mergeExtDexRelease UP-TO-DATE
> Task :launcher:mergeReleaseResources UP-TO-DATE
> Task :launcher:compileReleaseShaders UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
> Task :launcher:generateReleaseAssets UP-TO-DATE
> Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
> Task :launcher:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
> Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
> Task :unityLibrary:compileReleaseShaders UP-TO-DATE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :launcher:validateSigningRelease UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseBuildConfig
> Task :unityLibrary:FirebaseApp.androidlib:processReleaseManifest
> Task :unityLibrary:FirebaseApp.androidlib:extractDeepLinksRelease
> Task :unityLibrary:FirebaseApp.androidlib:javaPreCompileRelease
> Task :unityLibrary:FirebaseApp.androidlib:prepareLintJarForPublish UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseShaders
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseShaders
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseAssets
> Task :unityLibrary:FirebaseApp.androidlib:packageReleaseAssets
> Task :unityLibrary:FirebaseApp.androidlib:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseJniLibFolders
> Task :unityLibrary:FirebaseApp.androidlib:parseReleaseLocalResources
> Task :unityLibrary:FirebaseApp.androidlib:bundleLibResRelease
> Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseNativeLibs
> Task :unityLibrary:FirebaseApp.androidlib:stripReleaseDebugSymbols
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:FirebaseApp.androidlib:copyReleaseJniLibsProjectOnly
> Task :unityLibrary:bundleLibResRelease UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseRFile
> Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE
> Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
> Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE
> Task :unityLibrary:copyReleaseJniLibsProjectOnly UP-TO-DATE
> Task :unityLibrary:processReleaseManifest
> Task :launcher:mergeReleaseAssets
> Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseJavaWithJavac
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseLibraryResources
> Task :unityLibrary:FirebaseApp.androidlib:bundleLibCompileRelease
> Task :unityLibrary:FirebaseApp.androidlib:bundleLibRuntimeRelease
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
> Task :launcher:processReleaseManifest
> Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
> Task :unityLibrary:bundleLibCompileRelease UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeRelease UP-TO-DATE
> Task :launcher:processReleaseResources
> Task :launcher:javaPreCompileRelease UP-TO-DATE
> Task :launcher:compileReleaseJavaWithJavac UP-TO-DATE
> Task :launcher:compileReleaseSources UP-TO-DATE
> Task :launcher:lintVitalRelease
> Task :launcher:dexBuilderRelease UP-TO-DATE
> Task :launcher:mergeDexRelease UP-TO-DATE
> Task :launcher:mergeReleaseJavaResource UP-TO-DATE
> Task :launcher:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:stripReleaseDebugSymbols UP-TO-DATE
> Task :launcher:packageRelease FAILED
68 actionable tasks: 27 executed, 41 up-to-date
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launcher:packageRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.ide.common.signing.KeytoolException: Failed to read key mediabias from store "C:\Users\ahmed\Media Bias Game\user.keystore": Keystore was tampered with, or password was incorrect
* 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 2s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx7644m" "assembleRelease"
stderr[
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launcher:packageRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.ide.common.signing.KeytoolException: Failed to read key mediabias from store "C:\Users\ahmed\Media Bias Game\user.keystore": Keystore was tampered with, or password was incorrect
* 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 2s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
> Configure project :launcher
WARNING: The option 'android.enableR8' is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2020.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :launcher:generateReleaseBuildConfig UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:packageReleaseRenderscript NO-SOURCE
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
> Task :launcher:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :launcher:mainApkListPersistenceRelease UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseResValues
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseResources
> Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :launcher:prepareLintJar UP-TO-DATE
> Task :launcher:mergeReleaseShaders UP-TO-DATE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
> Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:packageReleaseResources
> Task :launcher:mergeExtDexRelease UP-TO-DATE
> Task :launcher:mergeReleaseResources UP-TO-DATE
> Task :launcher:compileReleaseShaders UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
> Task :launcher:generateReleaseAssets UP-TO-DATE
> Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
> Task :launcher:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
> Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
> Task :unityLibrary:compileReleaseShaders UP-TO-DATE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :launcher:validateSigningRelease UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseBuildConfig
> Task :unityLibrary:FirebaseApp.androidlib:processReleaseManifest
> Task :unityLibrary:FirebaseApp.androidlib:extractDeepLinksRelease
> Task :unityLibrary:FirebaseApp.androidlib:javaPreCompileRelease
> Task :unityLibrary:FirebaseApp.androidlib:prepareLintJarForPublish UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseShaders
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseShaders
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseAssets
> Task :unityLibrary:FirebaseApp.androidlib:packageReleaseAssets
> Task :unityLibrary:FirebaseApp.androidlib:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseJniLibFolders
> Task :unityLibrary:FirebaseApp.androidlib:parseReleaseLocalResources
> Task :unityLibrary:FirebaseApp.androidlib:bundleLibResRelease
> Task :unityLibrary:FirebaseApp.androidlib:mergeReleaseNativeLibs
> Task :unityLibrary:FirebaseApp.androidlib:stripReleaseDebugSymbols
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:processReleaseJavaRes NO-SOURCE
> Task :unityLibrary:FirebaseApp.androidlib:copyReleaseJniLibsProjectOnly
> Task :unityLibrary:bundleLibResRelease UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:generateReleaseRFile
> Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE
> Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE
> Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE
> Task :unityLibrary:copyReleaseJniLibsProjectOnly UP-TO-DATE
> Task :unityLibrary:processReleaseManifest
> Task :launcher:mergeReleaseAssets
> Task :unityLibrary:generateReleaseRFile UP-TO-DATE
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseJavaWithJavac
> Task :unityLibrary:FirebaseApp.androidlib:compileReleaseLibraryResources
> Task :unityLibrary:FirebaseApp.androidlib:bundleLibCompileRelease
> Task :unityLibrary:FirebaseApp.androidlib:bundleLibRuntimeRelease
> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
> Task :launcher:processReleaseManifest
> Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
> Task :unityLibrary:bundleLibCompileRelease UP-TO-DATE
> Task :unityLibrary:bundleLibRuntimeRelease UP-TO-DATE
> Task :launcher:processReleaseResources
> Task :launcher:javaPreCompileRelease UP-TO-DATE
> Task :launcher:compileReleaseJavaWithJavac UP-TO-DATE
> Task :launcher:compileReleaseSources UP-TO-DATE
> Task :launcher:lintVitalRelease
> Task :launcher:dexBuilderRelease UP-TO-DATE
> Task :launcher:mergeDexRelease UP-TO-DATE
> Task :launcher:mergeReleaseJavaResource UP-TO-DATE
> Task :launcher:mergeReleaseNativeLibs UP-TO-DATE
> Task :launcher:stripReleaseDebugSymbols UP-TO-DATE
> Task :launcher:packageRelease FAILED
68 actionable tasks: 27 executed, 41 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>: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 <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, 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 <c77ced6644e541b7ad3d7315a5e92a0a>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
【问题讨论】:
【参考方案1】:这是因为 'android.enableR8' 已被弃用。要从 gradle.properties 文件中删除它,您必须转到 Project Settings > Player > (Android Tab) > Other Settings > 并标记“Custom Gradle Properties Template”。
之后在“Assets/Plugins/Android/gradleTemplate.properties”处生成一个 gradleTemplate.properties 文件。
在此文件中删除“android.enableR8”行或将其注释掉,然后重新构建。
这个技巧应该有效。
【讨论】:
我已将其删除,但仍显示 ''' 启动 Gradle 守护程序,无法重用 1 个不兼容的守护程序,请使用 --status 了解详细信息 > 配置项目:launcher 警告:选项 'android.enableR8 ' 已被弃用,不应再使用。它将在未来版本的 Android Gradle 插件中删除,并且不再允许您禁用 R8。 ''' 导出为 android 项目,然后在 android studio 上进行更改。在 android studio 中,您可以更好地控制这些事情。以上是关于将统一游戏导出为 android APK 问题的主要内容,如果未能解决你的问题,请参考以下文章