anchor.diff:      echo "ready" >&2
       
       ${stdenv.lib.optionalString (app != null) ''
  -      # Install the App through the debugger
  +      # Install the App through the debugger, if it has not been installed yet
         
  -      if [ -d "${app}" ]
  +      if [ -z "${package}" ] || [ "$(adb -s emulator-$port shell 'pm list packages | grep -x package:${package}')" = "" ]
         then
  -          appPath="$(echo ${app}/*.apk)"
  -      else
  -          appPath="${app}"
  +          if [ -d "${app}" ]
  +          then
  +              appPath="$(echo ${app}/*.apk)"
  +          else
  +              appPath="${app}"
  +          fi
  +          
  +          ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port install "$appPath"
         fi
  -      
  -      ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port install "$appPath"
       
         # Start the application
         ${stdenv.lib.optionalString (package != null && activity != null) ''
  
positive.code:       # Store the virtual devices somewhere else, instead of polluting a user's HOME directory
        export ANDROID_SDK_HOME=$(mktemp -d $TMPDIR/nix-android-vm-XXXX)
      '' else ''
        export ANDROID_SDK_HOME=${avdHomeDir}
      ''}
      
      # We have to look for a free TCP port
  
negative.code:     mkdir -p $out/bin
      
      cat > $out/bin/run-test-emulator << "EOF"
      #! ${stdenv.shell} -e
      
      # We need a TMPDIR
      if [ "$TMPDIR" = "" ]
  