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-studio can't work with read-only sdk from nixstore #14903

Closed
jagajaga opened this issue Apr 22, 2016 · 13 comments
Closed

android-studio can't work with read-only sdk from nixstore #14903

jagajaga opened this issue Apr 22, 2016 · 13 comments

Comments

@jagajaga
Copy link
Member

So the name tells it all. Using the latest android-studio from master I can't create a new project because of that error.
Imgur

@jagajaga
Copy link
Member Author

cc @the-kenny

@jagajaga
Copy link
Member Author

jagajaga commented Apr 22, 2016

The solution I've found is to use this nix-shell configuration. Download both android-studio and android-sdk from google and run it. Also I've told android-studio that my android-sdk is located in a folder of extracted android-sdk I've downloaded from google.

@the-kenny
Copy link
Contributor

Good to hear you got it working! I wonder why android-studio even needs writable paths. Things like react-native work just fine. Did you try if the fhsUserEnv allows you to install other sdk packages via the android tool?

@Mathnerd314
Copy link
Contributor

This seems similar to #8650.

@bobvanderlinden
Copy link
Member

bobvanderlinden commented May 26, 2016

@jagajaga That seems to me like the way to go for Android development. Is there some way to get that into nixpkgs in a clean manner? At the moment Android Studio seems useless on NixOS without such FHS additions. The package for Steam seems to do something similar.

Edit:
@the-kenny it doesn't seem to me you can install packages using android, as pkgs.androidenv.androidsdk_6_0_extras is being used as ANDROID_HOME. It might be better to put androidsdk in $HOME and let android/android-studio do its thing with packages. It does go against the philosophy behind NixOS, but the applications seem too entangled and reliant on writable ANDROID_HOME to be practical. It seems similar to how Steam is working atm.

@Sicaine
Copy link

Sicaine commented Jun 27, 2016

Is it possible to fix this through the package itself or is the nix-shell the only solution?

@phunehehe
Copy link
Contributor

@jagajaga I wonder how do you deal with missing development headers as described in http://stackoverflow.com/q/29241640/168034?

@jagajaga
Copy link
Member Author

jagajaga commented Jul 4, 2016

@phunehehe somehow :)

@phunehehe
Copy link
Contributor

@jagajaga I hoped that somehow doesn't involve invoking apt-get :)

@bjornfor
Copy link
Contributor

bjornfor commented Jul 4, 2016

Isn't there something that can be done here? I mean, we got steam packaged...!

@bobvanderlinden
Copy link
Member

bobvanderlinden commented Jul 4, 2016

See #8650 (comment). Basically use buildFHSChrootEnv to create a chroot environment that looks like Debian and run Android Studio and android inside it. It is possible to do this as a package in nixpkgs, but I haven't found how yet. Steam seems to use a similar scheme, so that would be a first step.

The chroot will allow the use of binaries like mksdcard without patching. When that works, it should be possible to use android for package management. I'd set ANDROID_HOME to your home directory (probably ~/.android) or some other user-writable directory and let android figure out its dependencies on its own.

This is far from ideal what you want on NixOS, but I don't see a practical alternative. Handling dependencies of Android in NixOS (like how it is packaged right now) seems like maintenance hell. A lot needs to be patched to get the IDE working: both Android Studio and android can be used to handle Android packages, so they both need to be patched. In addition any binary that android downloads needs to be patched with the right rpaths to the right versions of libraries. Making android and Android Studio handle the dependencies themselves seems like a more practical solution.

@phunehehe
Copy link
Contributor

@bobvanderlinden thanks! I just discovered that in parallel too, by looking for lib32, seeing build-fhs-chrootenv among the results and "oh wait this looks familiar to that shell.nix thing" :)

phunehehe added a commit to phunehehe/nixpkgs that referenced this issue Aug 10, 2016
This commit fixes 2 main problems:

  - Android Studio comes with its own package manager. The current
    packaging approach doesn't allow such management. As a result the
    package is unusable (see
    NixOS#8650 and
    NixOS#14903). In this version,
    $ANDROID_HOME is _not_ set, allowing Android Studio to deal with the
    Android SDK as it pleases (typically in $HOME/Android/Sdk).

  - Android Studio downloads prebuilt binaries as part of the SDK. These
    tools (e.g. `mksdcard`) have `/lib/ld-linux.so.2` set as the
    interpreter. An FHS environment is used as a work around for that.
@Profpatsch
Copy link
Member

Thank you very much, @phunehehe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants