androidsdk: fix buildApp and emulateApp functions by providing the right executable paths + fix android emulator by adding dbus to the library path

This commit is contained in:
Sander van der Burg 2016-09-01 13:56:35 +00:00
parent c2841f1c1d
commit b17cd148ba
4 changed files with 14 additions and 14 deletions

View File

@ -1,7 +1,7 @@
{ stdenv, stdenv_32bit, fetchurl, unzip, makeWrapper
, platformTools, buildTools, support, supportRepository, platforms, sysimages, addons
, libX11, libXext, libXrender, libxcb, libXau, libXdmcp, libXtst, mesa, alsaLib
, freetype, fontconfig, glib, gtk, atk, file, jdk, coreutils, libpulseaudio
, freetype, fontconfig, glib, gtk, atk, file, jdk, coreutils, libpulseaudio, dbus
, zlib, glxinfo, xkeyboardconfig
}:
{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false, useGooglePlayServices ? false }:
@ -84,7 +84,7 @@ stdenv.mkDerivation rec {
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 mesa alsaLib zlib libpulseaudio ]} \
--suffix LD_LIBRARY_PATH : `pwd`/lib64:`pwd`/lib64/qt/lib:${makeLibraryPath [ stdenv.cc.cc libX11 libxcb libXau libXdmcp libXext mesa alsaLib zlib libpulseaudio dbus.lib ]} \
--suffix QT_XKB_CONFIG_ROOT : ${xkeyboardconfig}/share/X11/xkb
done
''}

View File

@ -19,7 +19,7 @@ in
stdenv.mkDerivation ({
name = stdenv.lib.replaceChars [" "] [""] name;
ANDROID_HOME = "${androidsdkComposition}/libexec/android-sdk-${platformName}";
ANDROID_HOME = "${androidsdkComposition}/libexec";
buildInputs = [ jdk ant ] ++
stdenv.lib.optional useNDK [ androidndk gnumake gawk file which ];

View File

@ -40,7 +40,7 @@ rec {
androidsdk = import ./androidsdk.nix {
inherit (pkgs) stdenv fetchurl unzip makeWrapper;
inherit (pkgs) zlib glxinfo freetype fontconfig glib gtk atk mesa file alsaLib jdk coreutils libpulseaudio;
inherit (pkgs) zlib glxinfo freetype fontconfig glib gtk atk mesa file alsaLib jdk coreutils libpulseaudio dbus;
inherit (pkgs.xorg) libX11 libXext libXrender libxcb libXau libXdmcp libXtst xkeyboardconfig;
inherit platformTools buildTools support supportRepository platforms sysimages addons;

View File

@ -42,7 +42,7 @@ stdenv.mkDerivation {
for i in $(seq 5554 2 5584)
do
if [ -z "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb devices | grep emulator-$i)" ]
if [ -z "$(${androidsdkComposition}/libexec/platform-tools/adb devices | grep emulator-$i)" ]
then
port=$i
break
@ -61,10 +61,10 @@ stdenv.mkDerivation {
# Create a virtual android device for testing if it does not exists
if [ "$(${androidsdkComposition}/libexec/android-sdk-*/tools/android list avd | grep 'Name: device')" = "" ]
if [ "$(${androidsdkComposition}/libexec/tools/android list avd | grep 'Name: device')" = "" ]
then
# Create a virtual android device
yes "" | ${androidsdkComposition}/libexec/android-sdk-*/tools/android create avd -n device -t ${if useGoogleAPIs then "'Google Inc.:Google APIs:"+platformVersion+"'" else "android-"+platformVersion} $NIX_ANDROID_AVD_FLAGS
yes "" | ${androidsdkComposition}/libexec/tools/android create avd -n device -t ${if useGoogleAPIs then "'Google Inc.:Google APIs:"+platformVersion+"'" else "android-"+platformVersion} $NIX_ANDROID_AVD_FLAGS
${stdenv.lib.optionalString enableGPU ''
# Enable GPU acceleration
@ -77,24 +77,24 @@ stdenv.mkDerivation {
fi
# Launch the emulator
${androidsdkComposition}/libexec/android-sdk-*/tools/emulator -avd device -no-boot-anim -port $port $NIX_ANDROID_EMULATOR_FLAGS &
${androidsdkComposition}/libexec/tools/emulator -avd device -no-boot-anim -port $port $NIX_ANDROID_EMULATOR_FLAGS &
# Wait until the device has completely booted
echo "Waiting until the emulator has booted the device and the package manager is ready..." >&2
${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port wait-for-device
${androidsdkComposition}/libexec/platform-tools/adb -s emulator-$port wait-for-device
echo "Device state has been reached" >&2
while [ -z "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell getprop dev.bootcomplete | grep 1)" ]
while [ -z "$(${androidsdkComposition}/libexec/platform-tools/adb -s emulator-$port shell getprop dev.bootcomplete | grep 1)" ]
do
sleep 5
done
echo "dev.bootcomplete property is 1" >&2
#while [ -z "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ]
#while [ -z "$(${androidsdkComposition}/libexec/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ]
#do
#sleep 5
#done
@ -106,7 +106,7 @@ stdenv.mkDerivation {
${stdenv.lib.optionalString (app != null) ''
# Install the App through the debugger, if it has not been installed yet
if [ -z "${package}" ] || [ "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell pm list packages | grep package:${package})" = "" ]
if [ -z "${package}" ] || [ "$(${androidsdkComposition}/libexec/platform-tools/adb -s emulator-$port shell pm list packages | grep package:${package})" = "" ]
then
if [ -d "${app}" ]
then
@ -115,12 +115,12 @@ stdenv.mkDerivation {
appPath="${app}"
fi
${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port install "$appPath"
${androidsdkComposition}/libexec/platform-tools/adb -s emulator-$port install "$appPath"
fi
# Start the application
${stdenv.lib.optionalString (package != null && activity != null) ''
${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
${androidsdkComposition}/libexec/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
''}
''}
EOF