I just upgraded from Unity 3.5.7 to 4.1.2. I built to Android with no problems on Unity 3, but right now I cannot build using Unity 4 and I can’t seem to find out why. Here is the error which is produced in Unity:
Error building Player: Exception: android (invokation failed)
ERROR: unknown error
cmd:android list target -c
stdout;
stderr:
Exception in thread "main" java.lang.NullPointerException
at SDKMain.main(SDKMain.java:62)
I found the answer/current workaround in another Unity Answers thread.
The problem seems to be caused by using Android SDK Tools revision 22, and can be fixed by reverting to revision 21. To do this:
- Open the Android SDK Manager, select Android SDK Tools and then click Delete Packages and confirm deletion.
- Download revision 21 of the SDK tools here:
- Extract the zip’s contents to your android-sdk folder, typically in
C:\Program Files (x86)\Android\android-sdk
for Windows, and overwrite any existing files.
- Run Android SDK Manager again and install the Android SDK Platform-tools package.
- Select the SDK path again in Unity if it isn’t already, and attempt to build again.
What worked for me (on mac):
- download the r21
- copy it into a different location than the original Android SDK and set
that new location in Unity
- copy over the platform folders (platform-3…-17)
- copy all tools and build-tools executables into both tools and
platform-tools
- I vaguely remember I had already patched up the Android environment for Unity 3.5x, I
think I had also copied aapt, lib and dx into the platform-17 folder
there is probably some unnecessary stuff in the above list, but it got me back into a working state
For me, simply copying the tools folder from the r21 zip over my android-sdk ools\ folder did the trick. (Be sure to close ADB etc).
Upon restarting the SDK manager, it listed the version as 21 (with 22 available) for “Android SDK Tools”, and I was able to successfuly download “Android SDK Platform-tools”
Thanks for the nudge in the right direction Daveoh\mrueger.
I created a zip with r21 based on mrueger post.
Simply extract it to any folder, then set unity to work with it (edit, preferences, external tool, Android SDK Location).
You can download from here.