compile and run Android apps from the console

5,321

I had the same problem until I found a memory error. If you can't upgrade your memory here's what you can do:

  1. Install dependencies:

    sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jdk ant gcc-multilib g++-multilib
    sudo apt-get install ia32-libs ## if applicable
    sudo apt-get install ant1.7 ant-optional
    
  2. Export paths:

    Open .bashrc file using an editor. If you use VI then vi ~/.bashrc and add the following 2 lines in your .bashrc file.

    JAVA_HOME=/usr/lib/jvm/jdk1.7.0_04/
    export JAVA_HOME
    

    Also, you can add these to compile from anywhere:

    open: .profile

    export PATH=$PATH:~/development/android-sdk-linux/tools
    export PATH=$PATH:~/development/android-sdk-linux/platform-tools
    
    if [ -d "$JAVA_HOME/bin" ] ; then
      PATH="$HOME/bin:$PATH"
    fi
    
  3. Configure the android simulator:

    android avd
    

    And you can setup your simulator there

  4. Build:

    ant debug
    

    or

    ant clean debug
    

    You might need to run:

    android update project --target <your build target> --path <path to LunarLander example>
    

    if you get:

    Buildfile: build.xml does not exist!
    Build failed
    
  5. Install the app:

    adb install ./bin/app-debug.apk
    

Sources:

Share:
5,321

Related videos on Youtube

Pat R Ellery
Author by

Pat R Ellery

SOreadytohelp Share!

Updated on September 18, 2022

Comments

  • Pat R Ellery
    Pat R Ellery over 1 year

    I installed eclipse and all the sdk/jre etc... I can make Android Apps now and it's working, but often my eclipse crash.

    I would like to know if it's possible to:

    • compile
    • build
    • run

    from the command line?

    I use VIM to edit the files

    • Pat R Ellery
      Pat R Ellery over 10 years
      I tried android studio but it was very slow and crashed too.
    • Jason Conti
      Jason Conti over 10 years
      It is possible, they tell you how in the android getting started tutorial: developer.android.com/training/basics/firstapp/… Just jump down to 'Create a Project with Command Line Tools'
  • Pat R Ellery
    Pat R Ellery over 10 years
    omg it works, thank you very much ... super fast to build as well +1.