Use a variable to set the base directory for Android development
authorAntonio Ospite <ao2@ao2.it>
Tue, 6 Oct 2015 10:55:05 +0000 (12:55 +0200)
committerAntonio Ospite <ao2@ao2.it>
Tue, 6 Oct 2015 10:55:05 +0000 (12:55 +0200)
android-app-development-getting-started.sh
setenv

index 971aa72..faee212 100755 (executable)
@@ -5,11 +5,11 @@
 #
 # Similar to
 # http://vishalraj.in/blogs/hello-world-writing-my-first-android-app-on-linux
 #
 # 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
+ANDROID_BASE_DIR=$HOME/Android
+
+mkdir $ANDROID_BASE_DIR
+cd $ANDROID_BASE_DIR
 
 # Download and unpack the SDK from
 # http://developer.android.com/sdk/index.html
 
 # Download and unpack the SDK from
 # http://developer.android.com/sdk/index.html
@@ -17,7 +17,7 @@ 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
 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 ANDROID_HOME=$ANDROID_BASE_DIR/android-sdk-linux
 export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
 
 # List packages
 export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
 
 # List packages
@@ -37,16 +37,16 @@ sudo aptitude install ant
 
 # Create a Hello World application
 # http://developer.android.com/tools/projects/projects-cmdline.html
 
 # Create a Hello World application
 # http://developer.android.com/tools/projects/projects-cmdline.html
-mkdir $HOME/Android/Apps
+mkdir $ANDROID_BASE_DIR/Apps
 android create project \
        --target android-17 \
        --name MyFirstApp \
 android create project \
        --target android-17 \
        --name MyFirstApp \
-       --path $HOME/Android/Apps/MyFirstApp \
+       --path $ANDROID_BASE_DIR/Apps/MyFirstApp \
        --activity MainActivity \
        --package com.example.myfirstapp
 
 # And maybe you want to use git for your App?
        --activity MainActivity \
        --package com.example.myfirstapp
 
 # And maybe you want to use git for your App?
-cd $HOME/Android/Apps/MyFirstApp
+cd $ANDROID_BASE_DIR/Apps/MyFirstApp
 ant clean
 git init
 git add .
 ant clean
 git init
 git add .
@@ -63,7 +63,7 @@ http://developer.android.com/training/basics/firstapp/building-ui.html
 
 # Build the App
 # http://developer.android.com/tools/building/building-cmdline.html
 
 # Build the App
 # http://developer.android.com/tools/building/building-cmdline.html
-cd $HOME/Android/Apps/MyFirstApp
+cd $ANDROID_BASE_DIR/Apps/MyFirstApp
 ant debug
 
 # Start the emulator, hardware accelerated:
 ant debug
 
 # Start the emulator, hardware accelerated:
diff --git a/setenv b/setenv
index b9a1569..004eee1 100644 (file)
--- a/setenv
+++ b/setenv
@@ -2,5 +2,7 @@
 
 [ "${0#-}" = "$(basename $SHELL)" ] || { echo "This script is meant to be sourced, not executed" 1>&2; exit 1; }
 
 
 [ "${0#-}" = "$(basename $SHELL)" ] || { echo "This script is meant to be sourced, not executed" 1>&2; exit 1; }
 
-export ANDROID_HOME=$HOME/Android/android-sdk-linux
+ANDROID_BASE_DIR=$HOME/Android
+
+export ANDROID_HOME=$ANDROID_BASE_DIR/android-sdk-linux
 export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
 export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools