Unity command line doesn't find android sdk

Hi, I’ve got a problem using unity3d command line for building an android apk…
I’m using Jenkins to manage the building and to see the unity3d output.
My problem is that Unity doesn’t find my android-sdk and the building seems go in an endless loop with a “detecting android-sdk…” output.
My unity preferences are set up well, because if I build with Unity3d opened everything build and runs well… Is there a way to specify the android sdk directory in the command line or via code?

I also looked for the unity path in the windows register and the androidsdk path is correct… I’m running windows 7 and I have another jenkins istance installed on a Mac with another copy of Unity that works fine… The only difference from the two command lines are the “-nographics” added in the windows version… because of that I have no idea of what could be wrong, someone has an hint?

1 Like

Have the same problem:
I use Jenkins ver. 1.493, Unity3D 4.0 on Windows 7 64 bit

Have no idea how to fix it.

Nobody? :frowning:

I try to do the same task with Unity 3.5 (Windows 7 64 bit) - everything works fine…

Yes, it’s correct because everything works fine if I compile it from Unity itself…

Did you change something in your settings or it worked as-is?

What’s the command line for build apk ? I didn’t found it here : Unity - Manual: Command-line arguments?
I am look for the command line for build ios to.

Thx

I’m experiencing the same issue on MacOS 10.8 + Unity 4.1.5 + TeamCity. My command line is:
/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -quit -projectPath %teamcity.build.checkoutDir% -executeMethod ProjectBuilder.DeployAndroid

If I build from inside the Editor everything works fine, but calling it from TeamCity (through command line) Unity asks me for the location for the android sdk, rendering the automate build useless as I have to be checking into it from time to time.

Any updates on this problem? Using Unity 4.3.1f1 is still prompting for the Android SDK every time it’s run from command line.

Anyone have tried this :
http://www.dannygoodayle.com/2013/03/04/setting-up-your-system-for-unity-android-development/

Or set “Android path” to the environment var “PATH” ?

Hey everybody, just in case someone runs into this the future, I found the solution to this problem here:

I created a new class with this exact code

using UnityEditor;

public static class AndroidSDKFolder
{
	public static string Path
	{
		get { return EditorPrefs.GetString("AndroidSdkRoot"); }
		set { EditorPrefs.SetString("AndroidSdkRoot", value); }
	}
}

I set the property when the automated build is triggered right before Unity starts it’s build player process. Hope this helps!

offfffffffffffffffffffffffffffffffffffffffffffffffff

Error building Player: Win32Exception: ApplicationName=‘C:/Users/Cengiz Ve Ailesi/AppData/Local/Android/android-sdk\tools\aapt.exe’, CommandLine=‘package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S “res” -I “C:/Users/Cengiz Ve Ailesi/AppData/Local/Android/android-sdk\platforms\android-20\android.jar” -F bin/resources.ap_’, CurrentDirectory=‘Temp/StagingArea’

error boring

Excellent. Thank you! I was beating my head against the wall and then found this :slight_smile:

It works like a charm.

Thanks!

As this problem is related specifically to Jenkins, do this:

  • Go to Jenkins > Manage Jenkins > Configure System
  • Check “Environment variables”
  • add name: ANDROID_HOME, and the value:
  • click “Add”

Do the same for ANDROID_NDK_HOME.

source: Week One: Setup Jenkins to build Android App using Gradle | by @jothedev | Medium

In addition, see all the relevant environment variables here: android - How do I set ANDROID_SDK_HOME environment variable? - Stack Overflow