From: Antonio Ospite Date: Tue, 6 Oct 2015 10:55:05 +0000 (+0200) Subject: Use a variable to set the base directory for Android development X-Git-Url: https://git.ao2.it/android/android-app-development-getting-started.git/commitdiff_plain/0f30c7c101e4df20f31888c5466a64b6fc8f34b4?ds=inline Use a variable to set the base directory for Android development --- diff --git a/android-app-development-getting-started.sh b/android-app-development-getting-started.sh index 971aa72..faee212 100755 --- a/android-app-development-getting-started.sh +++ b/android-app-development-getting-started.sh @@ -5,11 +5,11 @@ # # 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 @@ -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 -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 @@ -37,16 +37,16 @@ sudo aptitude install ant # 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 \ - --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? -cd $HOME/Android/Apps/MyFirstApp +cd $ANDROID_BASE_DIR/Apps/MyFirstApp 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 -cd $HOME/Android/Apps/MyFirstApp +cd $ANDROID_BASE_DIR/Apps/MyFirstApp ant debug # Start the emulator, hardware accelerated: diff --git a/setenv b/setenv index b9a1569..004eee1 100644 --- 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; } -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