Search Unity

Android build not working

Discussion in 'Android' started by mantra_dev, Mar 12, 2020.

  1. mantra_dev

    mantra_dev

    Joined:
    Mar 22, 2017
    Posts:
    2
    Hey guys I hope you can help me with this issue so many people seem to be getting. Im having trouble building and android app for oculus go.
    .
    I have followed this guide using android studio:
    https://docs.unity3d.com/2018.3/Documentation/Manual/android-sdksetup.html
    .
    .
    I started with a playstation pro version of Unity.
    Downgraded project to used Unity 7.3 then downloaded and tested on Unity tested on 5.6 both personal additions. Same errors asking for SDK.
    .
    2018.3.14f
    Clean installed this version twice
    .
    .
    I downloaded android studio. After installing all of the SDKs in Android studio with SDK manager (and unhiding the AppData folder in windows 10), i got success and no longer had SDK path pop ups. I did get build errors, which from the forum posts and unity instructions, I downgraded the Java JDK pack from 9 to 8. From then i got a lot of errors and Player preferences in Project settings went blank. At this point i have reinstalled Unity again, created new projects and opened old and its back to asking for an SDK path again and saying that there are no SDKs in the directory.
    .
    .
    Now I tried to reinstall Android Studio. Even though all of the SDKs are showing up in the manager Unity still cant find them in the path. "Unable to detect SDK". I have just tried using the command prompt tool for installing the packages. Did my best to follow the instructions, but the commands didnt seem to be really working. Saying "warning could not create settings".
    .
    .
    .
    .
    .
    .
    .
    .
    .
    Capture.JPG Capture1.JPG Capture3.JPG Capture4.JPG
     
  2. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    836
    Hi, in the first screenshot you have "SDK Platforms" tab selected. Try to select "SDK Tools" tab and check if you have platform tools, build tools, and tools (3 separate components) installed. If you are using Android Studio 3.6 or newer, then tools component will be hidden as obsolete. You have to uncheck "Hide Obsolete Packages" and then it will show up in "SDK Tools" tab. All of these 3 components have to be installed.
     
  3. Sosa17

    Sosa17

    Joined:
    Jun 20, 2013
    Posts:
    4
    Hi man, just to give you a way to solve this ( I did this)

    try to use the commands in this way: sdkmanager --sdk_root=%ANDROID_HOME% "platform-tools" "platforms;android-27" "build-tools;27.0.3
     
  4. Deleted User

    Deleted User

    Guest

    I decided to login after one hell of a time not being active anymore just for the sole purpose of providing an answer. In my opinion I find it extremely sloppy from Google to publish their command line tools with such a clear bug in it. And the solution @Sosa17 provides is in this case perfect.

    In fact, I even went a step further and modified the sdkmanager.bat file instead as the change was so minimal. This solution applies to Windows only although I am certain you can do a similar change in the bash script the Linux version of the Android SDK tools are providing. The batch file is located in your %ANDROID_HOME%\tools\bin folder. And all you have to do is change this line from:

    "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%  -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS%


    to

    "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%  -classpath "%CLASSPATH%" com.android.sdklib.tool.sdkmanager.SdkManagerCli %CMD_LINE_ARGS% --sdk_root=%ANDROID_HOME%


    Obviously assuming you set your ANDROID_HOME environment variable. In this case the SDK expects it to be set to the folder where your "tools" folder is located.
     
    hembrom likes this.
  5. hembrom

    hembrom

    Joined:
    Aug 25, 2018
    Posts:
    1
    Finally Solved after hours.....Thanks!!!
     
  6. erro12

    erro12

    Joined:
    May 7, 2017
    Posts:
    1
    After a whole night search for the solution, finally!!!