Open Bug 1221253 Opened 9 years ago Updated 2 years ago

Look for and use Android Studio SDK in mobile/android |mach boostrap|

Categories

(Firefox Build System :: General, defect)

defect

Tracking

(Not tracked)

People

(Reporter: nalexander, Unassigned, Mentored)

References

Details

(Whiteboard: [lang=python][good next bug])

Most Android developers use Android Studio, which packages an Android SDK internally.  This ticket tracks searching for Android Studio in known locations (depending on OS), looking for the packaged Android SDK, and offering to use it (and upgrade it) rather than downloading another one.
This is a [good next bug] for a Python developer.
Mentor: nalexander
Whiteboard: [lang=python][good next bug]
What we want here is a simple search for SDK folder like in "C:/Program Files/"(For Windows) or search for android studio in installed programs list(like in registry for windows) followed by a full disk search(in other drives as well) for any other possible occurrences of android studio?
(In reply to Harshit Bansal from comment #2)
> What we want here is a simple search for SDK folder like in "C:/Program
> Files/"(For Windows) or search for android studio in installed programs
> list(like in registry for windows)

Yes, just a few well-known locations...

 followed by a full disk search(in other
> drives as well) for any other possible occurrences of android studio?

No, this will take forever and be unlikely to find something.  Folks who move their installation around can find a way to configure their mozconfig without |mach bootstrap|.

Thanks for trying this!
For clarity, Windows shouldn't be an issue with this correct?
(In reply to Mark Capella [:capella] from comment #4)
> For clarity, Windows shouldn't be an issue with this correct?

What do you mean?  We'll look in Windows spots (possibly only on Windows), and in Linux, and in Mac OS X spots.

Building Fennec on Windows isn't supported at all.  Although, artifact builds should basically work: I fixed https://bugzilla.mozilla.org/show_bug.cgi?id=1220476 while trying to get them to work and haven't had time to try again.
I am unable to find the default installation folder for sdk on linux and Mac os. I have googled them without any satisfactory answer. Could you please tell me their default location?
Also, are there any environment variables that I should check?
(In reply to Harshit Bansal from comment #6)
> I am unable to find the default installation folder for sdk on linux and Mac
> os. I have googled them without any satisfactory answer. Could you please
> tell me their default location?

Not so easy to find.  On Mac OS X, looks like we should check if /Applications/Android Studio*.app/sdk/tools/android exists (where the * means shell globbing, since there may be a version number?).  See the screen shot in http://stackoverflow.com/q/16594611.

If we make the mechanism work for Mac OS X, then we can file follow-up for Linux paths, since these are probably distribution specific.

> Also, are there any environment variables that I should check?

Good idea: it would be great if we looked in ANDROID_HOME and ANDROID_SDK_HOME first.  I'm not sure what the standard name is, could you investigate?

Environment variables are likely to help Linux users, who are likely to set their environment.  (Mac users are not likely to set their environment.)

Good question, hope this helps.  Thanks for digging in!
Flags: needinfo?(nalexander)
On OS X, you can also check the default brew install location:
  /usr/local/opt/android-sdk
  /usr/local/opt/android-ndk

Note that some users may unknowingly install both an SDK with Android Studio and one with brew so there could be a conflict.
Over time I accumulated three SDK installations on MacOS X. I just throw them in here in the hope that his might be useful. None of the three is listed above:

  /Users/sebastian/Library/Android/sdk/ - No idea how this ended up here but ANDROID_HOME actually points to this location and so I'm using it in my mozconfig.

  /usr/local/Cellar/android-sdk/ - I assume brew did that. This folder does not contain the SDK but has subfolders for different versions of the SDK (totally confusing), currently: 24.3.2   24.3.3   24.3.4

  /Users/sebastian/.mozbuild/android-sdk-macosx/ - I assume |mach bootstrap| created this one?
> Not so easy to find.  On Mac OS X, looks like we should check if
> /Applications/Android Studio*.app/sdk/tools/android exists (where the *
> means shell globbing, since there may be a version number?).  See the screen
> shot in http://stackoverflow.com/q/16594611.

 Looks like in OSX sdk resides in ~/Android/sdk by default
I think, one way to fix this bug is to have a list of all the directories where the Android SDK might be present(depending on the OS). If the Android SDK is not found in any of the directories, then, we should download the SDK to the first location mentioned in the list of directories and reflect the same location in the suggested mozconfig details.
Flags: needinfo?(nalexander)
(In reply to Sambuddha Basu [:sambuddhabasu1] from comment #11)
> I think, one way to fix this bug is to have a list of all the directories
> where the Android SDK might be present(depending on the OS). If the Android
> SDK is not found in any of the directories, then, we should download the SDK
> to the first location mentioned in the list of directories and reflect the
> same location in the suggested mozconfig details.

Yes, exactly.  The trick is to find the list for each OS, but you seem to be good at running VMs to do such things.

Thanks!
Flags: needinfo?(nalexander)
Product: Core → Firefox Build System
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.