Unity 打包错误:CommandInvokationFailure: Failed to build apk.

我的环境:

Android JDK/JRE 9.0.1

Unity 2017.2.0f3

最近因为换了电脑,很多开发环境都要重新配置,今天在刚刚把Android环境搭建好(JDK/JRE/SDK等),用Unity打包APK的时候居然提示打包失败???




错误信息:

CommandInvokationFailure: Failed to build apk.
F:/Android/Environment/JDK/jdk-9.0.1\bin\java.exe




原因:

Google 了好久,原因是因为JDK版本引起的,截止2018/1/14 JDK 版本是9.0.1。



解决方案:

如果你使用的是JDK9.0.1版本的话那就悲剧了,网上没有找到基于JDK 9的APK发布失败解决方案。很多老外都是通过将JDK 降级到 JDK8 然后修改 系统变量JAVA_HOME 和Unity  Edit ->Preferences->Extenal Tools->Android JDK 导向到JDK8,然后再打包的。


总结:

通过查看了一些论坛的回帖,应该是JDK9 删除了一些关于Sun.相关API导致的。

总之就是不要用JDK9 来打包,换用JDK8

发布了18 篇原创文章 · 获赞 31 · 访问量 12万+
展开阅读全文

unity转apk出现错误,求大神解答

10-03

错误代码有两个 第一个 CommandInvokationFailure: Failed to build apk. C:/Program Files/Java/jdk-9\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="D:/Program Files/android-sdk-windows\tools" -Dfile.encoding=UTF8 -jar "D:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" - stderr[ Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at SDKMain.main(SDKMain.java:130) Caused by: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder at com.android.sdklib.internal.build.SignedJarBuilder.<init>(SignedJarBuilder.java:177) at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:446) at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:422) at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:362) at UnityApkBuilder.<init>(UnityApkBuilder.java:214) at UnityApkBuilder.main(UnityApkBuilder.java:34) ... 5 more Caused by: java.lang.ClassNotFoundException: sun.misc.BASE64Encoder at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ... 11 more ] stdout[ ] exit code: 1 UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.HostView:OnGUI() 第二个 UnityEditor.BuildPlayerWindow+BuildMethodException: Build failed with errors. at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x001b9] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:162 at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00050] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:83 UnityEditor.HostView:OnGUI() 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览