-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: repackage in an FHS environment #16752
Conversation
Can you please put the PR cover message into the commit (the "motivation for this change")? |
Please also grep for existing android studio in pkgs. And do something with it. Cc @offlinehacker |
@@ -0,0 +1,49 @@ | |||
{ pkgs ? import <nixpkgs> {} }: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take each parameter you need "{ coreutils, findutils, ..." instead of "pkgs ? import {}".
Please also take the liberty of removing android-studio and buildAndroidStudio from ideas in your commit to avoid any future confusion. Perhaps that is what @jagajaga meant but better to be explicit. |
58d52e4
to
b7a5dcd
Compare
@phunehehe: Good! You say it "works for me", does that mean everything [you've done] is working? Or is there (still) issues that makes Nix + android-studio a pain? |
@bjornfor admittedly I'm not a hardcore Android guy anymore, but everything I want to use works. That includes installing SDK components, importing an app and debugging it with a hardware device (via adb). I haven't tried using a virtual device though, not very useful IMO. |
LGTM |
@bjornfor can you please test this PR? I can't do it these days. |
@jagajaga: Sure. Note that I have no prior experience with android-studio, so it'll be from a novice' perspective. |
I thought I'd just mention a few people for feedback (and possibly test): @bobvanderlinden, @geraldus, @Radivarig |
Some testing notes. After starting android-studio and running the setup wizard, a dialog window pops up:
I can only click "retry" or "cancel". Pressing "retry" just shows the same message agin and "cancel" shows the installer log:
Is it trying to run prebuilt binaries without correct interpreter (e.g. /lib/ld-linux.so)? I can move forward by clicking "finish" at this point and see the Welcome screen where I can chose e.g. "Start a new Android Studio Project". However, selecting that results in:
Going there (Configure -> ...) I see two misconfigurations (highlighted in the status bar), the "Android SDK location" is empty (I set it to ~/Android/Sdk (because I noted that path during the setup wizard). Then there is the blocker: "Please choose a valid JDK directory". The JDK location is already filled: /nix/store/3y10awsnnf20hv66gbr06dm821czgi42-openjdk-8u102b04/lib/openjdk, but apparently the wizard doesn't like that path (or it actually is wrong). Any ideas? |
Ah, the existing path was to openjdk, but Android Studio wants to oraclejdk . Using the |
@bjornfor I wonder how |
@phunehehe: I've started android-studio before, a couple of weeks ago. I obviously didn't get very far because that version fails do install the SDK due to the read-only Nix store. But I think that version was using openjdk... I think I remember a warning in android-studio exactly about that ("expect issues with openjdk, better use oracklejdk" or something like that). Maybe it simply remembered the previous JDK path? |
I created an empty project using the wizard. There were some warnings and finally some fatal build errors. Part of the problem was solved by downloading more stuff via Android Studio (it showed what to do). But still the build failed, from the Gradle build log:
(I'm on x86_64-linux NixOS.) |
I wanted to have a look at the issue with our existing android studio. This time I tried starting with a clean state (I hope this is enough... at least it's enough to force the the setup wizard on the next run):
At startup the wizard complains that /nix/store/.../libexec/android-sdk-linux is not writeable. I point it to ~/android-sdk-linux instead and the setup continues. Like the fhs-version, this one also is "Unable to run mksdcard SDK tool", presumably due to missing 32-bit libs. I continued on and created a new / empty project. This time however, there are no build errors and I see a preview of the application (I don't think it's the real emulator) in the middle of the IDE. What were the issues with android-studio again?? |
Refreshed my memory a bit and got feedback from @svanderburg (#8650 (comment)). At this point I'm thinking we shouldn't replace android-studio with the FHS variant (like this PR does), but if anything, add it on the side (android-studio-fhs?). Thoughts? |
@bjornfor sorry, I have no NixOS installed at this moment. |
I saw the "mksdcard" error before. It was gone after converting to FHS. I have now cleared my state files and it's coming back. Should be fixable, I'll track it down. Same for "libz", I included zlib specifically for that. Can't reproduce it yet because of the "mksdcard" problem, but again should be fixable. I gave up on the existing android-studio package after seeing a startup dialog without text (screenshot below) and the issues linked from the top comment. As for android-studio and/or android-studio-fhs, there are many ways to reason about it, but I think the most practical way is, what's the capacity of the community? From easiest to hardest:
It seems like we have some form of (2), which nobody uses (that's the impression I have after going through all the android-studio issues, though I'm happy to be corrected). Does it make sense to admit we don't have the bandwidth, and try to at least make (1) work? |
^ I realize that might come across as harsh. As you can see in the top comment, my original intention was to ask whether this new package should replace the existing package. |
@phunehehe: I didn't pick up any "harshness" :-) That screenshot looks like it comes from Ubuntu. On NixOS it does have text: Maybe that "missing text" thing is a generic issue on non-NixOS (i.e. not related to android-studio in particular)? I hope we can have option (3): support both imperative and declarative setups. I'm going to play a bit more with android-studio (with/without FHS). |
@bjornfor For me it's fine to have an android-studio in an FHS user/chroot environment. Of course, having a Nix-deployed version using the Nix-deployed Android SDK is nice for some purposes, but probably inconvenient in many other areas. |
I don't understand why the FHS userenv/chroot should make a difference as to where the SDK is located (in read-only nix store or not). The FHS chroot just appears to have a traditional filesystem layout, but that doesn't make every directory writeable. I tried running existing android-studio with a modified expression, to remove $ANDROID_HOME (was: (Of course, still fails to run mksdcard, but this PR doesn't change that.) @edwtjo: Any thoughts on the ANDROID_HOME setting (a46065c)? |
@bjornfor I have been playing a bit and my memory is coming back. Certain Android build tools are shipped as 32 bit binaries https://code.google.com/p/android/issues/detail?id=82711. I don't think it's possible to support that with a normal package, which was why I started this PR in the first place. I think the actual fix (multiPkgs) got lost in the various "improvements" I made 😊 The "no text" problem went away with Oracle JDK 8, I guess it works on NixOS due to some supporting environment variables. But that doesn't matter anymore given the 32 bit binaries. For cleaning up state to test, be sure to remove I have a working thing that I should be able to push shortly. |
@bjornfor I refer to my comment a year ago #8650 (comment) that I'm in favour of removing ANDROID_HOME from the wrapper. So far no one using android-studio has done so but it seems like it is the most appropriate change to get studio into a workable state, well that and passing oraclejdk. |
So... what's blocking here? I think this is the third time I'm rebasing to fix conflicts. |
@phunehehe: Oh, I guess I missed you comment from ~2 weeks ago. I didn't know you had updated the PR. I'll test locally and merge. |
@bjornfor: Thanks. One thing I'm not sure about is the package names |
@phunehehe: If it was me doing the change I would have kept the attribute name But I'm OK with merging as is. I often become overly focused on details, trying not to let it take over :-) |
The driver issues you mention (https://gist.github.com/phunehehe/3390ef17fae770f6028c7776a39fb641) might be due to #9415 ("libGL not working on non-NixOS (without setting up)"). I'll probably add that emulator patch at some point myself, no worries. |
@phunehehe: Let me know if you want me to merge. |
7aae4f4
to
ac6c051
Compare
@bjornfor: Agree on the overriding, somehow it never occurred to me. The latest update addressed that. As for
Ideas? (No pun intended.)
|
It works here (master, 5fbe282):
That override is for |
Oh, now I see there were two comments with override examples. Anyway, does it work for you now? |
@bjornfor The "matches no derivations" error only appears after putting in the override. It seems you can't override
Or at least, that lets me install the package by name. However, the override doesn't have any effect, as the package still uses openjdk:
|
I'm not sure how to debug this, but I imagine it's related to the recurseIntoAttrs and how the 'jdk' attribute is inherited from an outer scope, rather than being a direct function argument to the inner mkDerivation. As the expression is written on current master, I think the override must be applied on the ideas attrset itself, and it will override all of the ideas packages. |
@bjornfor Then let's merge this as is? Unless someone else shows up of course. |
@phunehehe: Hm, if you agree with my suggestions, of course I'd like to see them implemented before merge :-) But I'm rather busy now (for up to 3 weeks), so ... :-/ |
@bjornfor would it help if I "revoke" my agreement :) |
As a full-time Android engineer, I'm seeing two use cases which suggest two approaches to the problem.
I'm not convinced a full FHS hierarchy is necessary to achieve (2). What I would suggest is for Nix to package just the 32-bit binaries which cause problems and to have users fudge the path themselves or manually create emulator images using the Nix-patched binaries. The problems I care about daily are not running emulators but simply keeping the Java libraries and Maven repos up to date, and there are plenty of alternative solutions to running the official emulator. |
Sorry for butting in here, but why isn't this getting merged? I'm also currently using jagajaga configuration as the current package is unusable. |
Please rebase |
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.
ac6c051
to
f822b93
Compare
@globin: done |
So, I think I've run into a bug related to this, and I'm not sure if it's a NixOS problem or not. I'm trying to build microG as part of AOSP in a FHS env, and I keep getting a license error from the Android Gradle plugin:
I have followed the instructions in that link, but it seems like nothing I try results in the Gradle plugin picking up the license acceptances. For reference, I've installed:
So yeah. Any ideas what's the cause of this? |
@spacekitteh not related at all :) |
# { | ||
# packageOverrides = pkgs: { | ||
# android-studio = pkgs.android-studio.override { | ||
# jdk = pkgs.oraclejdk8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably remove this warning. Openjdk seems to be the gold standard now.
Motivation for this change
Android (studio) can and wants to manage its own packages. The current packaging approach doesn't allow such management. As a result the package is unusable (see #8650 and #14903).
@jagajaga has a nix-shell configuration, which I have adapted into a package. The quality is pretty much "work for me", but hey, it works :)
Oracle JDK is a nuisance to install (unfree and requires a manual download), but I got an exception with Open JDK and I have little clue how to continue that way.
Would this be nearly good enough to replace the current package?
Things done
(nix.useChroot on NixOS,
or option
build-use-chroot
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)