summary refs log tree commit diff
path: root/pkgs/development/mobile/androidenv/androidsdk.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/mobile/androidenv/androidsdk.nix')
-rw-r--r--pkgs/development/mobile/androidenv/androidsdk.nix73
1 files changed, 40 insertions, 33 deletions
diff --git a/pkgs/development/mobile/androidenv/androidsdk.nix b/pkgs/development/mobile/androidenv/androidsdk.nix
index 5f61f25d54ee..a463adaf731f 100644
--- a/pkgs/development/mobile/androidenv/androidsdk.nix
+++ b/pkgs/development/mobile/androidenv/androidsdk.nix
@@ -4,10 +4,18 @@
 , freetype, fontconfig, glib, gtk2, atk, file, jdk, coreutils, libpulseaudio, dbus
 , zlib, glxinfo, xkeyboardconfig
 , includeSources
+, licenseAccepted
 }:
-{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false
+{ platformVersions, abiVersions, useGoogleAPIs, buildToolsVersions ? [], useExtraSupportLibs ? false
 , useGooglePlayServices ? false, useInstantApps ? false }:
 
+if !licenseAccepted then throw ''
+    You must accept the Android Software Development Kit License Agreement at
+    https://developer.android.com/studio/terms
+    by setting nixpkgs config option 'android_sdk.accept_license = true;'
+  ''
+else assert licenseAccepted;
+
 let inherit (stdenv.lib) makeLibraryPath;
 
     googleRepository = let version = "gms_v9_rc41_wear_2_0_rc6";
@@ -20,16 +28,16 @@ in
 
 stdenv.mkDerivation rec {
   name = "android-sdk-${version}";
-  version = "25.2.5";
+  version = "26.1.1";
 
   src = if (stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux")
     then fetchurl {
-      url = "https://dl.google.com/android/repository/tools_r${version}-linux.zip";
-      sha256 = "0gnk49pkwy4m0nqwm1xnf3w4mfpi9w0kk7841xlawpwbkj0icxap";
+      url = "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip";
+      sha256 = "1yfy0qqxz1ixpsci1pizls1nrncmi8p16wcb9rimdn4q3mdfxzwj";
     }
     else if stdenv.hostPlatform.system == "x86_64-darwin" then fetchurl {
-      url = "http://dl.google.com/android/repository/tools_r${version}-macosx.zip";
-      sha256 = "0yg7wjmyw70xsh8k4hgbqb5rilam2a94yc8dwbh7fjwqcmpxgwqb";
+      url = "https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip";
+      sha256 = "0gl5c30m40kx0vvrpbaa8cw8wq2vb89r14hgzb1df4qgpic97cpc";
     }
     else throw "platform not ${stdenv.hostPlatform.system} supported!";
 
@@ -39,7 +47,7 @@ stdenv.mkDerivation rec {
     unpackFile $src
     cd tools
 
-    for f in android traceview draw9patch hierarchyviewer monitor ddms screenshot2 uiautomatorviewer monkeyrunner jobb lint
+    for f in monitor bin/monkeyrunner bin/uiautomatorviewer
     do
         sed -i -e "s|/bin/ls|${coreutils}/bin/ls|" "$f"
     done
@@ -54,24 +62,6 @@ stdenv.mkDerivation rec {
           patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib $i
       done
 
-      ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
-        for i in bin64/{mkfs.ext4,fsck.ext4,e2fsck,tune2fs,resize2fs}
-        do
-            patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
-            patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i
-        done
-      ''}
-
-      ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
-        # We must also patch the 64-bit emulator instances, if needed
-
-        for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service emulator-check qemu/linux-x86_64/qemu-system-*
-        do
-            patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
-            patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i
-        done
-      ''}
-
       # The following scripts used SWT and wants to dynamically load some GTK+ stuff.
       # Creating these wrappers ensure that they can be found:
 
@@ -79,22 +69,18 @@ stdenv.mkDerivation rec {
         --prefix PATH : ${jdk}/bin \
         --prefix LD_LIBRARY_PATH : ${makeLibraryPath [ glib gtk2 libXtst ]}
 
-      wrapProgram `pwd`/uiautomatorviewer \
-        --prefix PATH : ${jdk}/bin \
-        --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
-
-      wrapProgram `pwd`/hierarchyviewer \
+      wrapProgram `pwd`/bin/uiautomatorviewer \
         --prefix PATH : ${jdk}/bin \
         --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
 
       # The emulators need additional libraries, which are dynamically loaded => let's wrap them
 
       ${stdenv.lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
-        for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service
+        for i in emulator emulator-check
         do
             wrapProgram `pwd`/$i \
               --prefix PATH : ${stdenv.lib.makeBinPath [ file glxinfo ]} \
-              --suffix LD_LIBRARY_PATH : `pwd`/lib64:`pwd`/lib64/qt/lib:${makeLibraryPath [ stdenv.cc.cc libX11 libxcb libXau libXdmcp libXext libGLU_combined alsaLib zlib libpulseaudio dbus.lib ]} \
+              --suffix LD_LIBRARY_PATH : `pwd`/lib:${makeLibraryPath [ stdenv.cc.cc libX11 libxcb libXau libXdmcp libXext libGLU_combined alsaLib zlib libpulseaudio dbus.lib ]} \
               --suffix QT_XKB_CONFIG_ROOT : ${xkeyboardconfig}/share/X11/xkb
         done
       ''}
@@ -134,9 +120,17 @@ stdenv.mkDerivation rec {
 
     cd ..
     ln -s ${platformTools}/platform-tools
-    ln -s ${buildTools}/build-tools
     ln -s ${support}/support
 
+    mkdir -p build-tools
+    cd build-tools
+
+    ${stdenv.lib.concatMapStrings
+       (v: "ln -s ${builtins.getAttr "v${builtins.replaceStrings ["."] ["_"] v}" buildTools}/build-tools/*")
+       (if (builtins.length buildToolsVersions) == 0 then platformVersions else buildToolsVersions)}
+
+    cd ..
+
     # Symlink required Google API add-ons
 
     mkdir -p add-ons
@@ -245,6 +239,14 @@ stdenv.mkDerivation rec {
         fi
     done
 
+    for i in $out/libexec/tools/bin/*
+    do
+        if [ ! -d $i ] && [ -x $i ]
+        then
+            ln -sf $i $out/bin/$(basename $i)
+        fi
+    done
+
     for i in $out/libexec/platform-tools/*
     do
         if [ ! -d $i ] && [ -x $i ]
@@ -260,6 +262,11 @@ stdenv.mkDerivation rec {
             ln -sf $i $out/bin/$(basename $i)
         fi
     done
+
+    wrapProgram $out/bin/sdkmanager \
+      --set JAVA_HOME ${jdk}
+
+    yes | ANDROID_SDK_HOME=$(mktemp -d) $out/bin/sdkmanager --licenses || true
   '';
 
   buildInputs = [ unzip makeWrapper ];