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

androidenv: android licenses #67661

Closed
wants to merge 1 commit into from
Closed

Conversation

spinus
Copy link
Member

@spinus spinus commented Aug 28, 2019

Motivation for this change

Android SDK requires accepted licenses, those are save in specific location and looks like android tools construct paths based on their location, rather than env variables (which means they are looking in nix store and user is not able to add them setting environment variable [at least I didn't find how to do it]).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @svanderburg

@spinus
Copy link
Member Author

spinus commented Nov 1, 2019

who would be right person to check here?

Comment on lines +262 to +263
mkdir $out/licenses
${builtins.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (k: v: "echo -e '\n${v}' > $out/licenses/${k}") licenses))}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what is your use case. I have spent some time this week playing with this PR trying to run a React Native project. In the end it turned out that for my project I didn't need any special license, it was enough with config.android_sdk.accept_license = true.

In any case, when using this branch I realized that the licenses folder is created in the root of the package. However, the SDK is inside libexec/android-sdk so there is no way to configure $ANDROID_HOME so both the licenses and the tools are found. I think that the licenses folder should be inside the SDK folder.

-      mkdir $out/licenses
-      ${builtins.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (k: v: "echo -e '\n${v}' > $out/licenses/${k}") licenses))}
+      ${builtins.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (k: v: "echo -e '\n${v}' > $out/libexec/sdk-manager/licenses/${k}") licenses))}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dicearr I didn't manage to work my react-native with that, but I found adding this license stuff just progressed me a little further so wanted to share. I didn't try accept_licnese though.

Would you mind sharing your setup for local dev / emulator and releasing process? Currently I'm using docker with openjdk to provide this environments as I didn't mange to do it in Nix, I emulator from nix though.
If you have this working I would be happy to document it and put in NixOS docs as this stuff is not very well described.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a run-android.nix file which is a combination of the android documentation with #72220 (comment). Executing $ nix-shell run-android.nix should make the application run in the device/emulator.

with import <nixpkgs> {
  config.android_sdk.accept_license = true;
};

let androidComposition = androidenv.composeAndroidPackages {
  toolsVersion = "25.2.5";
  platformVersions = [ "28" ];
};

in (buildFHSUserEnv {
  name = "react-native-env";
  targetPkgs = pkgs: ([
    androidComposition.androidsdk
    glibc
    openjdk
    nodejs-12_x
  ]);
  runScript = ''
    ;ANDROID_HOME=${androidComposition.androidsdk}/libexec/android-sdk \
      $(npm bin)/react-native run-android
  '';
})

.env

@Mic92
Copy link
Member

Mic92 commented Nov 29, 2019

cc @svanderburg

@lucafavatella
Copy link
Contributor

@spinus @svanderburg Is this PR still applicable - or does the user approval via config.android_sdk.accept_license = true; make this not needed?

@spinus Your insight may help in PR #82118 - where I update the package-related generated expressions. Would you please consider having a look at that PR, and prepare a branch for any changes you may envisage. Thanks!

@spinus
Copy link
Member Author

spinus commented Apr 18, 2020

@lucafavatella sorry for delay. I've seen your PR but I was not skilled yet with it to provide constructive feedback. Thank for pushing this. Looks like good chunk of work, I guess I'm closing this one in that case. Cheers.

@spinus spinus closed this Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants