Cannot build on Android, possible SDK issues

Hello. I have been working on an AR app for both Android and iOS. Most of development took place on Unity 5.5.2 or earlier.

After making an update to multiple related stuff - JDK, android SDK, Unity - I get some errors related to android sdk path and android tools (see complete log bellow).

After searching the interwebs for a solution, I tried the following:

  • downgrading android tools to 25.3.2
  • trying various versions of unity: 2017.1, 5.6.1, 5.2.2
  • completely reinstalling JDK and android SDK
  • combinations of the above

Do you have any other suggestions?

Here are the 4 error messages I get:

Error:Invalid command android

UnityEditor.HostView:OnGUI()


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/jdk1.8.0_131\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir=“C:/Users/rleu/AppData/Local/Android/sdk\tools” -Dfile.encoding=UTF8 -jar “C:\Program Files\Unity5.5.2\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()


Error building Player: 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/jdk1.8.0_131\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir=“C:/Users/rleu/AppData/Local/Android/sdk\tools” -Dfile.encoding=UTF8 -jar “C:\Program Files\Unity5.5.2\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar” -

stderr[
Error:Invalid command android
]
stdout[

]
exit code: 64


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()

Finally found a fix. All I had to do was to delete the existing version of the app on my phone. The problem was probably caused by the way Unity handles making default signatures for android builds

Looks like a similar issue to this one: unity game engine - Unable to merge android manifests. See the Console for more details - Stack Overflow

See my answer in that link.

@liortal we’ve fixed the issue long ago. Just update the Unity version to a latest patch release.

When was this fixed? i believe the bug was marked as fixed, but later people still complained it’s not working (there was another error about manif merger).

Android: Fix android application building with the latest android sdk
2017.1b2
5.6.0p3
5.5.3p3

Android: Fix manifest merging with new android sdk tools
2017.1b3
5.6.0p4
5.5.3p4

There’s an active issue with build tools 26.0.0 but it’s a bug on the google side which will be fixed soon Unity 2017.1 Android build error - Unity Engine - Unity Discussions

Please report any other issues you meet!