Search Unity

Unity command line doesn't find android sdk

Discussion in 'Editor & General Support' started by WiLLyRS, Dec 18, 2012.

  1. WiLLyRS

    WiLLyRS

    Joined:
    Jul 4, 2012
    Posts:
    8
    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?
     
    turfur likes this.
  2. Churs

    Churs

    Joined:
    Dec 18, 2012
    Posts:
    3
    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.
     
  3. WiLLyRS

    WiLLyRS

    Joined:
    Jul 4, 2012
    Posts:
    8
    Nobody? :(
     
  4. Churs

    Churs

    Joined:
    Dec 18, 2012
    Posts:
    3
    I try to do the same task with Unity 3.5 (Windows 7 64 bit) - everything works fine...
     
  5. WiLLyRS

    WiLLyRS

    Joined:
    Jul 4, 2012
    Posts:
    8
    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?
     
  6. C4MProdDev

    C4MProdDev

    Joined:
    Jul 9, 2009
    Posts:
    107
  7. raphaelbaldi

    raphaelbaldi

    Joined:
    Mar 4, 2008
    Posts:
    23
    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.
     
  8. Vedad

    Vedad

    Joined:
    Sep 29, 2011
    Posts:
    29
    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.
     
  9. Rom7Nains

    Rom7Nains

    Joined:
    Jan 16, 2014
    Posts:
    1
  10. Vedad

    Vedad

    Joined:
    Sep 29, 2011
    Posts:
    29
    Hey everybody, just in case someone runs into this the future, I found the solution to this problem here:
    http://answers.unity3d.com/questions/495735/setting-android-sdk-path-in-environment-variable.html

    I created a new class with this exact code
    Code (csharp):
    1.  
    2. using UnityEditor;
    3.  
    4. public static class AndroidSDKFolder
    5. {
    6.     public static string Path
    7.     {
    8.         get { return EditorPrefs.GetString("AndroidSdkRoot"); }
    9.         set { EditorPrefs.SetString("AndroidSdkRoot", value); }
    10.     }
    11. }
    I set the property when the automated build is triggered right before Unity starts it's build player process. Hope this helps!
     
  11. turfur

    turfur

    Joined:
    Jul 22, 2015
    Posts:
    3
    offfffffffffffffffffffffffffffffffffffffffffffffffff
     
  12. turfur

    turfur

    Joined:
    Jul 22, 2015
    Posts:
    3
    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
     
  13. turfur

    turfur

    Joined:
    Jul 22, 2015
    Posts:
    3
     
  14. jimihay

    jimihay

    Joined:
    Mar 19, 2012
    Posts:
    15
    Excellent. Thank you! I was beating my head against the wall and then found this :)
     
  15. yanhui

    yanhui

    Joined:
    Aug 24, 2012
    Posts:
    5
     
  16. WiktorCal

    WiktorCal

    Joined:
    Mar 1, 2014
    Posts:
    4
    It works like a charm.

    Thanks!
     
  17. Skeldal

    Skeldal

    Joined:
    Apr 30, 2019
    Posts:
    12
  18. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    In addition, see all the relevant environment variables here: https://stackoverflow.com/a/46976475/6301627