3 # Tutorial about getting started with android App development from the command
 
   7 # http://vishalraj.in/blogs/hello-world-writing-my-first-android-app-on-linux
 
   9 ANDROID_BASE_DIR=$HOME/Android
 
  11 mkdir $ANDROID_BASE_DIR
 
  14 # Download and unpack the SDK from
 
  15 # http://developer.android.com/sdk/index.html
 
  16 wget http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz
 
  17 tar xzvf android-sdk_r24.3.4-linux.tgz
 
  19 # Add "platform-tools" and "tools" to the PATH
 
  20 export ANDROID_HOME=$ANDROID_BASE_DIR/android-sdk-linux
 
  21 export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
 
  24 android list sdk --all --extended
 
  26 # Install packages. Use this same command line to update the packages
 
  27 android update sdk --no-ui --all --filter tools,platform-tools,build-tools-23.0.1,android-17,sys-img-x86-android-17,extra-android-support
 
  29 # Check what targets are available
 
  32 # Create an Android Virtual Device (AVD)
 
  33 android create avd --target android-17 --name android-17-x86 --abi x86
 
  35 # Create a Hello World application
 
  36 # http://developer.android.com/tools/projects/projects-cmdline.html
 
  38 # Info on the latest version of the Android Gradle Plugin here:
 
  39 # https://developer.android.com/tools/revisions/gradle-plugin.html
 
  40 mkdir $ANDROID_BASE_DIR/Apps
 
  41 android create project \
 
  42         --gradle --gradle-version 1.3.1 \
 
  45         --path $ANDROID_BASE_DIR/Apps/MyFirstApp \
 
  46         --activity MainActivity \
 
  47         --package com.example.myfirstapp
 
  49 # Set a gradle version compatible with the Android Gradle Plugin used above,
 
  50 # see: http://tools.android.com/tech-docs/new-build-system/version-compatibility
 
  51 sed -e '/distributionUrl/s/gradle-[^\-]*-all/gradle-2\.5-all/g' -i $ANDROID_BASE_DIR/Apps/MyFirstApp/gradle/wrapper/gradle-wrapper.properties
 
  52 sed -e 's/runProguard false/minifyEnabled false/g' -i $ANDROID_BASE_DIR/Apps/MyFirstApp/build.gradle
 
  54 # And maybe you want to use git for your App?
 
  55 cd $ANDROID_BASE_DIR/Apps/MyFirstApp
 
  59 git commit -m $'Initial import\n\nhttp://developer.android.com/training/basics/firstapp/creating-project.html'
 
  60 echo ".gradle/" > .gitignore
 
  61 echo "build/" >> .gitignore
 
  62 echo "local.properties" >> .gitignore
 
  64 git commit -m "Add a .gitignore file"
 
  66 # Learn how to write Android Apps:
 
  67 xdg-open http://developer.android.com/training/basics/firstapp/building-ui.html
 
  70 # http://developer.android.com/tools/building/building-cmdline.html
 
  71 cd $ANDROID_BASE_DIR/Apps/MyFirstApp
 
  72 ./gradlew assembleDebug
 
  74 # Start the emulator, hardware accelerated:
 
  75 # http://developer.android.com/tools/devices/emulator.html#vm-linux
 
  76 emulator -verbose -avd android-17-x86 -scale 0.9 -gpu on -qemu -m 512 -enable-kvm
 
  78 # Install the App into an Android [Virtual] Device
 
  80 adb -s emulator-5554 install bin/MyFirstApp-debug.apk
 
  82 # Launch your application from the HOST
 
  83 adb -s emulator-5554 -e shell am start -a android.intent.action.MAIN -n com.example.myfirstapp/com.example.myfirstapp.MainActivity
 
  85 # See logs, e.g. only errors
 
  86 adb -s emulator-5554 logcat *:E
 
  88 # Connect to the emulator via telnet if needed