- Home /
Multiple issues when Testing and Building for Android (4.4.2)
First of all, I wanna apologize for such a massive post, I just thought it would be better to add every detail to help you all understand my predicament. It might be best to point out that I'm not too sure what I'm doing at this point, so bear with me. (I'm not even sure if this is the right place to post this...)
I've been working on this Android app for some time and have just recently decided to try building and running it on my old Samsung Galaxy Core (An SM-G386W model running Android Kit-Kat 4.4.2). The Unity version I'm using is 5.5.0f3 on a PC running Windows 10.
I've never actually built any app for any type of mobile device before, Unity or otherwise, Android or iOS, so I didn't have the slightest idea where to start, but I ended up following this tutorial: https://learn.unity.com/tutorial/building-formobile#5c7f8528edbc2a002053b4a2
I eventually reached the part where it says to “Download the Android SDK Tools rather than the full download of Android Studio.” and did just that, but I ran into some issues, given that the provided SDK Tools were too recent to be compatible with 4.4.2, so I then took the time to download Android Studio and manually pick all components to install, figuring that this may be the best course of action to take to fix my problem, only to realize it doesn't fix it at all...
After assigning the SDK Directory in Edit/Preferences/ExternalTools, I tried building the app, which prompted a popup window saying “Android SDK is outdated, SDK Build Tools Version 0 < 23”. If I press “Continue”, I end up with this message “Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details.” and this error code:
CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details. C:\Program Files\Java\jdk-13.0.1\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="D:/Unity/Android(SDK)/sdk-tools-windows-4333796\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\5.0\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" - stderr[ Error:Invalid command android ] stdout[ ] exit code: 64 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()
(Note: This is the path of the custom directory where I installed Android Studio as well as the individual SDK Tools(4333796) and I don't know if I should have installed it in Program Files or somewhere else instead, but it shouldn't make much of a difference as far as I'm concerned: D:/Unity/Android(SDK)/sdk-tools-windows-4333796)
If I press “Update Android SDK” instead, I end up with this message “Unable to update the SDK. Please run the SDK Manager manually to make sure you have the latest set of tools and the required platforms installed. See the Console for more details.” and this:
CommandInvokationFailure: Unable to update the SDK. Please run the SDK Manager manually to make sure you have the latest set of tools and the required platforms installed. See the Console for more details. C:\Program Files\Java\jdk-13.0.1\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="D:/Unity/Android(SDK)/sdk-tools-windows-4333796\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\5.0\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" android update sdk -a -u -t tool,platform-tool,build-tools-23.0.2 stderr[ Error:Invalid command android ] stdout[ ] exit code: 64 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()
It's pretty clear to me now that I haven't got the right version of the SDK Tools so I start looking it up. I first found this post, where user ARaction mentions what to do fix that very issue: https://answers.unity.com/questions/1323731/unable-to-list-target-platforms-please-make-sure-t.html
I then downloaded the r20 version of “Tools” from the provided download link, but I still can't tell the difference between that, SDK-Tools and Platform-Tools, so I tried changing the SDK directory nonetheless to select “D:/Unity/Android(SDK)/tools_r20-windows” instead... And I still get the same issue, only this time it says “SDK Tools version 20 < 24” instead of “SDK Tools version 0 < 23”. The main difference, however, is that now when I press “Update SDK”, it freezes for a minute as though it were actually updating, then returns the same error message, this time with “SDK Tools version 20 < 23”. I try it again. It freezes again and finally returns a different message saying “Android SDK is missing required platform api, minimum platform required is Android 6.0 (API level 23)”. I googled it up then decided to press the Update button for a third time. This time it almost worked, it just couldn't find any connected Android device, though I can clearly see the USB icon in the top left on the phone and the phone icon in the “Devices and Drives” section of “This PC”.
I then find this post relating how this may either be an issue with the USB and/or Developer options, in which case disabling them and re-enabling them may solve the issue, or that the USB cable may be a cheap one, designed only to charge and not to transfer data. However, if the cable was the issue, I wouldn't be able to look for files located on the phone from within the computer, but I actually can, so that's unlikely. I then try disabling and re-enabling Developer and USB options. No change. A google group user once mentioned having to check if the MTP protocol is active, although I can't see it anywhere, and according to this source here below, that may be because the SD card's format isn't FAT... but why would that make a difference, anyway? https://groups.google.com/forum/#!topic/android-porting/mYv79PQ-Nig
Another link mentions where the button is supposedly hidden to manually enable MTP, but I can't see that button anywhere in the Storage section. I've looked everywhere and trust me, it's not there and I have no idea why. http://www.random-host.com/blogs/enable-media-device-mtp-usb-mode-android-44-kitkat-and-50-lollipop
After all that, I'm thinking that the phone is just too old to be recognized by the SDK, hinting that the SDK Tools and/or Platform-Tools aren't compatible. Basically, I've got the wrong drivers. So I check the Device Manager and try to update the phone's driver, but the PC keeps telling me that “The Best Driver is already installed”. https://www.samsung.com/au/support/mobile-devices/computer-not-recognising-device/
So I figure I might as well download it from the source. (The latest version) https://developer.samsung.com/galaxy/others/android-usb-driver-for-windows
This clearly did something since the Phone has now been “Configured” as a device on the PC, presumably thanks to the new Driver. Unfortunately, Unity still can't detect it.
I then found out that I could download the proper SDK and NDK Tools directly by installing Unity from UnityHub, so I figured I might as well re-download Unity 5.5.0... Unfortunately, that version is too old and not supported by UnityHub.
I figured maybe I should try enabling the “Verify apps via USB” option in the phone and try building again. This time, I didn't get any pop-ups. It just kept going as though it was actually building the application, only to return this:
Win32Exception: ApplicationName='D:/Unity/Android(SDK)/tools_r20-windows\tools\aapt.exe', CommandLine='package --auto-add-overlay -v -f -m -J "gen" -M "AndroidManifest.xml" -S "res" -I "D:/Unity/Android(SDK)/tools_r20-windows\platforms\android-23\android.jar" -F bin/resources.ap_', CurrentDirectory='Temp/StagingArea' System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) System.Diagnostics.Process.Start () (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start () UnityEditor.Utils.Program.Start () (at C:/buildslave/unity/build/Editor/Mono/Utils/Program.cs:33) UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg, Int32 retriesOnFailure) UnityEditor.Android.PostProcessor.Tasks.BuildResources.CompileResources (UnityEditor.Android.PostProcessor.PostProcessorContext context) UnityEditor.Android.PostProcessor.Tasks.BuildResources.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry) UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (BuildPostProcessArgs args) UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:186) UnityEditor.HostView:OnGUI()
I'm no expert when it comes to error reports, but it seems to me like it actually did start building, only to fail halfway through. I tried again to make sure, but the same issue keeps happening. Is the Java version also wrong? I still don't even know whether the SDK Tools I have are right or not... I tried it again, this time changing the directory from “D:/Unity/Android(SDK)/tools_r20-windows” to “D:/Unity/Android(SDK)/tools_r25.2.5-windows”, and I still get the “Android SDK is outdated, SDK Build Tools Version 0 < 23” error. I press Update a second time, I get the “Android SDK is missing required platform api, minimum platform required is Android 6.0 (API level 23)” error. I press Update a third time and get a new error “Build Failure, failed to build apk. See the console for details.” then this:
CommandInvokationFailure: Failed to build apk. C:\Program Files\Java\jdk-13.0.1\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="D:/Unity/Android(SDK)/tools_r25.2.5-windows\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\5.0\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" - stderr[ Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,950 days for: CN=Android Debug, O=Android, C=US 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:567) at SDKMain.main(SDKMain.java:129) Caused by: java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder at com.android.sdklib.internal.build.SignedJarBuilder.(SignedJarBuilder.java:177) at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:446) at com.android.sdklib.build.ApkBuilder.(ApkBuilder.java:422) at com.android.sdklib.build.ApkBuilder.(ApkBuilder.java:362) at UnityApkBuilder.(UnityApkBuilder.java:212) 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:436) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 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()
It seems clear to me that last one had an issue involving Java, I'm just not sure what it is.
Also Unity Remote doesn't work either, and neither does the “Android.bat” batch file from any of the SDK sources. The command prompt just flashes for a split second on screen before shutting off automatically. I just thought I'd mention it, even though it may or may not be related to the other issues I've been having.
Seriously, how hard can it be to just give programmers the option to automatically download the necessary tools for any version of Android or iOS along with Unity?
I can't seem to figure out what I'm missing...
Your answer
Follow this Question
Related Questions
Android - Failed to repackage resources error after installing facebook plugin 2 Answers
Android build failed error 1 Answer
I have a build problem android. 0 Answers
Gradle Build Failed Unity version 2020..3.23 1 Answer
Android Build 0 Answers