Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Tuesday, May 15, 2018

CommandInvokationFailure: While Compiling for Android

While compiling for Android I got the following error:

CommandInvokationFailure: Failed to build apk. See the Console for details.
C:\Program Files\Java\jdk-10.0.1\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Program Files (x86)/Android/android-sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar"


Solution:

Use Java JDK 8. 

It seems that Unity 5.3.8 doesn't like JDK 9 or higher.
Downloaded 
jdk-8u171-windows-x64 from Oracle and install it.

Then in Unity under Edit > Preferences > External Tools point Unity to JDK 8.


Android SDK is outdated

I finished making the make screens for the game and it runs well when compiled for PC. Ultimately I want the game to run on Android and iOS so I thought I'd compile an APK file and try and get it running on my Samsung S6.

After following the instructions I found here: Building your Unity game to an Android device for testing

I installed Java JDK and Android Studio and pointed Unity to the tools directory that contains the Android SDK.


The Problem


However when I compiled for Android I kept getting the following messages:

"Android SDK is outdated" and "sdk tools version 23 < 24".

Unity then asked me if I wanted to update and after replying "yes" it went off, looped around a bit and then came back with same messages.



The Solution


All that was needed was for Unity to be running in Administrator mode.
Once in Administrator mode Unity managed to download what it needed and continue compiling.