Android Projekt can't be exported or created

Dear community,

I had the same problem already a couple of months ago, that Unity can’t recognize installed Android platforms,
at that time the error had been solved through installing the patch 5.6.1f1 and I was able to create and export projects again.
Last time the problem was that Google replaced the programm android with sdkmanager in a new version of its SDK.

Now the same error occures again:

The following erros are reported by Unity:
Error 1: Error:Invalid command android

UnityEditor.HostView:OnGUI()

Error 2: 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\User\AppData\Local\Android\Sdk\tools” -Dfile.encoding=UTF8 -jar “C:\Program Files\Unity\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 3:
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\User\AppData\Local\Android\Sdk\tools” -Dfile.encoding=UTF8 -jar “C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar” -

stderr[
Error:Invalid command android
]
stdout[

]
exit code: 64

It seems that Unity tries again to use android instead of sdkmanager.

Thanks for solutions,

Franz Reinhard Seidl
Software Engeneer

This was an issue with Unity and one of the newer versions of the Android SDK tools. For reference, here is the bug report on the issuetracker site: Unity Issue Tracker - Android Build fails when the latest Android SDK Tools 25.3.1 version is used

It is said to have been fixed in Unity 2017.1, so if you can upgrade, test using that version to see if the issue was resolved.

If not, you can apply the workaround as mentioned in this Stackoverflow question

My License isn’t valid for 2017.1 what’s the fault.

Message of Unity: Serial is not valid for this version of Unity. Please contact support@unity3d.com for more information.

Can some one give me more information?

Hi, Could you confirm what version of Unity you are on and what Android SDK version you are using. Are you managing the Android SDK via Android Studio/SDK Manager? Is this a problem that is happening with your existing project or does it happen on an empty project as well? Did it occur after an upgrade of Unity or Android SDK? What OS are you on? There might be some more follow up questions but let’s start with those.

Thanks.

I am using,

Android SDK:26.1.1(Managed by Android Studio/SDK-Manager)
Unity Version: 2017.1.0f3(Serial-Number isn’t valid)
Previous Version was: 5.6.1f1
OS: Windows
No Update of Unity in this time, Android yes,there were some updates.
In new Version the error still exists.
Error occures in new and existing Projekts.

Android Plugin has been installed after installing Unity.

Thanks

Hi Franz,

So has building to Android ever worked for you? What I’m trying to understand is what’s different between when it was fine and now. Also, I know it’s less than ideal,but have you tried the latest patch releases of 5.6 or 2017.1?

Yes it has worked, at the begin.
After update of the Android SDK the error occures for the first time and I couldn’t export anymore.
Then I got the Patch 5.6.1f1 and it was working again for a few months.
Now the error is back again.
I think that it’s an error of unity because of the first Error.

Error 1: Error:Invalid command android

UnityEditor.HostView:OnGUI()

I doesn’t know why, Unity tries again to call the command android instead of the new command sdkmanager introduced in newer Versions of Android SDK, to replace android.

Hi,

I’m really not sure what could be wrong here. Could you provide some screenshots of your player settings and build settings. I’d also recommend trying the most recent version of 5.6 (currently 5.6.3).

Also double check the SDK path is pointing where you expect under Preferences->External Tools.

OK I will upload this for you after downgrading Unity to 5.6.3f1

But I am sure that the error is the following.

Since a few Versions, Google has replaced the Command android by sdkmanager.
Now I read that Google Reintroduce the android as a batch Script in Version 26.0.0
(How Unity calls android ? as a Batch or as a java-Programm?)

Look this:

When running the android.bat from Console I get this:

android.bat list target


The “android” command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat


Invoking “C:\Users\User\AppData\Local\Android\sdk\tools\bin\avdmanager” list target

ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

After Setting JAVA_HOME:

I get this.

android.bat list target


The “android” command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools\bin\sdkmanager.bat
and tools\bin\avdmanager.bat


Invoking “C:\Users\User\AppData\Local\Android\sdk\tools\bin\avdmanager” list target

Available Android targets:==============] 100% Fetch remote repository…

id: 1 or “android-23”
Name: Android API 23
Type: Platform
API level: 23
Revision: 3

id: 2 or “android-25”
Name: Android API 25
Type: Platform
API level: 25
Revision: 3

There are the Screenshots:

Thanks,

Franz

Can you please post your full editor.log after the build has failed?
We are invoking android utility as a backward-compatibility action, after avdmanager has failed. Latest Unity versions (also within 5.6 cycle) and Android SDK versions should work.

Thanks for answering, but the Problem seems to be solved since 5.6.3p2.

I hope for ever.

1 Like