#!/usr/bin/env less # # Tutorial about getting started with android App development from the command # line shell. # # Similar to # http://vishalraj.in/blogs/hello-world-writing-my-first-android-app-on-linux # # The base working dir is assumed to be $HOME/Android mkdir $HOME/Android cd $HOME/Android # Download and unpack the SDK from # http://developer.android.com/sdk/index.html wget http://dl.google.com/android/android-sdk_r21.1-linux.tgz tar xzvf android-sdk_r21.1-linux.tgz # Add "platform-tools" and "tools" to the PATH export ANDROID_HOME=$HOME/Android/android-sdk-linux export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools # List packages android list sdk --extended # Install packages. Use this same command line to update the packages android update sdk --no-ui --filter platform-tools,android-17,sys-img-17,extra-android-support # Check what targets are available android list targets # Create an Android Virtual Device (AVD) android create avd --target android-17 --name android-17-x86 --abi x86 # Install "ant" to build packages sudo aptitude install ant # Create a Hello World application # http://developer.android.com/tools/projects/projects-cmdline.html mkdir $HOME/Android/Apps android create project \ --target android-17 \ --name MyFirstApp \ --path $HOME/Android/Apps/MyFirstApp \ --activity MainActivity \ --package com.example.myfirstapp # And maybe you want to use git for your App? cd $HOME/Android/Apps/MyFirstApp ant clean git init git add . git rm local.properties git commit -m $'Initial import\n\nhttp://developer.android.com/training/basics/firstapp/creating-project.html' echo "bin/" > .gitignore echo "gen/" > .gitignore echo "local.properties" > .gitignore git add .gitignore git commit -m "Add a .gitignore file" # Learn how to write Android Apps: http://developer.android.com/training/basics/firstapp/building-ui.html # Build the App # http://developer.android.com/tools/building/building-cmdline.html cd $HOME/Android/Apps/MyFirstApp ant debug # Start the emulator, hardware accelerated: # http://developer.android.com/tools/devices/emulator.html#vm-linux emulator -verbose -avd android-17-x86 -scale 0.9 -gpu on -qemu -m 512 -enable-kvm # Install the App into an Android [Virtual] Device adb devices -l adb -s emulator-5554 install bin/MyFirstApp-debug.apk # Launch your application from the HOST adb -s emulator-5554 -e shell am start -a android.intent.action.MAIN -n com.example.myfirstapp/com.example.myfirstapp.MainActivity # See logs, e.g. only errors adb -s emulator-5554 logcat *:E # Connect to the emulator via telnet if needed telnet localhost 5554