Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANDROID_SDK_ROOT does not point to an Android SDK #1499

Closed
t-arn opened this issue Oct 20, 2023 · 2 comments · Fixed by #1821
Closed

ANDROID_SDK_ROOT does not point to an Android SDK #1499

t-arn opened this issue Oct 20, 2023 · 2 comments · Fixed by #1821
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start!

Comments

@t-arn
Copy link

t-arn commented Oct 20, 2023

Describe the bug

When you want briefcase to use an already installed Android SDK (on Windows), you can set the environment variable ANDROID_SDK_ROOT or ANDROID_HOME.

When running briefcase create android you might get the following warning:

ANDROID_SDK_ROOT does not point to an Android SDK

even though the environment variable does point to the correct folder. The reason for the warning message is that the Android Sdk does not include the command-line tools.

Steps to reproduce

  1. Install Android Studio
  2. From Android Studio, install the Android SDK (without selecting the command-line tools)
  3. Set the environment variable ANDROID_SDK_ROOT or ANDROID_HOME to the Android/Sdk folder
  4. Run briefcase create android
  5. See error ANDROID_SDK_ROOT does not point to an Android SDK

Expected behavior

The error message should be more specific, e.g. no command-line tools found under the folder {ANDROID_SDK_ROOT}

Screenshots

No response

Environment

  • Operating System: Windows 11
  • Python version: 3.9, 3.10, 3.11
  • Software versions:
    • Briefcase: 0.3.15

Logs


Additional context

No response

@t-arn t-arn added the bug A crash or error in behavior. label Oct 20, 2023
@rmartin16 rmartin16 added the android The issue relates to Android mobile support. label Oct 20, 2023
@rmartin16
Copy link
Member

rmartin16 commented Oct 20, 2023

This is the specific error from v0.3.15:

*************************************************************************
** WARNING: ANDROID_SDK_ROOT does not point to an Android SDK          **
*************************************************************************

    The location pointed to by the ANDROID_SDK_ROOT environment
    variable:

    /opt/sdks/Android/sdk/

    doesn't appear to contain an Android SDK.

    Briefcase will use its own SDK instance.

*************************************************************************

With the release of v0.3.16, this error now presents like this:

*************************************************************************
** WARNING: ANDROID_SDK_ROOT does not point to an Android SDK          **
*************************************************************************

    The location pointed to by the ANDROID_SDK_ROOT environment
    variable:

    /opt/sdks/Android/sdk/

    doesn't appear to contain an Android SDK.

    If ANDROID_SDK_ROOT is an Android SDK, ensure it is the root directory
    of the Android SDK instance such that

    $ANDROID_SDK_ROOT/cmdline-tools/9.0/bin/sdkmanager

    is a valid filepath.

    Briefcase will proceed using its own SDK instance.

*************************************************************************

So, with the new Briefcase release, the reason the SDK is rejected is made somewhat clearer now IMO.

As for dealing with a user-specified SDK that doesn't contain the Command-line Tools....this is a bit messier. While the error suggests that version 9.0 is required, it can technically also make do with a version installed as "latest". However, it is required that one of these two versions of the Command-line Tools exists in an SDK to use it.....without those tools, Briefcase cannot ensure the SDK later contains the remaining parts of the SDK are installed (e.g. the emulator).

During the development of #1397, we did consider bootstrapping the Command-line Tools in to a user-specified SDK by downloading a copy and using it to install the Command-line Tools in to the user's SDK but this was ultimately rejected. FWIW, this seems to be how Android Studio is able to use an arbitrary existing SDK without any Command-line Tools...since it brings its own tools along with itself.

Given all this, unless we want to reconsider some of it, I'm not sure there's anything actionable necessarily.


(meta: after pushing #1397, it never was clear to me what an arbitrary directory must contain to be considered an Android SDK. Google seems to have created a _very_ mushy definition of what this SDK is....and what one needs to contain to be considered one. The SDK more seems like a collection of independent scripts and tools that amassed together organically instead of with a plan in mind ahead of time.....although, now, the SDK Manager in Android Studio can help hide a lot of this since you can build an SDK by clicking a bunch of checkboxes.)

@freakboy3742
Copy link
Member

Given all this, unless we want to reconsider some of it, I'm not sure there's anything actionable necessarily.

I think I agree, unless we want to make one small tweak to make the failure mode explicit by changing:

doesn't appear to contain an Android SDK.

to

doesn't appear to contain an Android SDK with the Command-line Tools installed.

@freakboy3742 freakboy3742 added the good first issue Is this your first time contributing? This could be a good place to start! label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start!
Projects
None yet
3 participants