Skip to content

Instantly share code, notes, and snippets.

@derekbrameyer
Created December 10, 2012 21:20
Show Gist options
  • Select an option

  • Save derekbrameyer/4253522 to your computer and use it in GitHub Desktop.

Select an option

Save derekbrameyer/4253522 to your computer and use it in GitHub Desktop.
Zero to Android Deploy

1. Install Android SDKs

  • Navigate to http://developer.android.com/sdk/index.html#ExistingIDE
  • "Download the SDK Tools for Mac"
  • Copy the android-sdk-macosx directory to your Home directory.
  • Navigate to android-sdk-macosx/tools and execute android
  • You may need to allow Gatekeeper to install from anywhere
    • Settings --> Security & Privacy --> "Allow applications downloaded from: Anywhere"
  • When opening android, if you do not have a Java Runtime, OS X will download it for you (you'll have to relaunch android once the runtime is installed)
  • Check off the following packages:
    • Android SDK Platform-tools (Rev. 16)
    • Android 4.2 --> SDK Platform
    • Android 4.2 --> ARM EABI v7a System Image
    • Android 4.1 --> SDK Platform
    • Extras --> Android Support Library
    • Extras --> Intel x86 Emulator Accelerator (HAXM)
  • Click "Install 6 packages..."
  • Click the "Accept All" radio button and click "Install"
  • Install HAXM
    • Navigate to android-sdk-macosx/extras/intel/Hardware_Accelerated_Execution_Manager and execute IntelHAXM.dmg
    • It will unpack. Double-click the .dpkg and follow the instructions, using the defaults.

2. Add platform-tools and tools to your path and launchd.conf:

  • Launch Terminal

nano ~/.bash_profile

  • -Edit ~/.bash_profile to add these at the end:

export ANDROID_HOME=~/android-sdk-macosx

export PATH=$PATH:~/android-sdk-macosx/platform-tools

export PATH=$PATH:~/android-sdk-macosx/tools

  • Close nano

source ~/.bash_profile

sudo nano /etc/launchd.conf

  • -Edit launchd.conf to add these at the end:

setenv M2_HOME /usr/share/maven

setenv ANDROID_HOME /Users/YOURUSERNAMEHERE/android-sdk-macosx

setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/

  • You should now be able to run adb from the command line. Try running adb devices The console should output List of devices attached with identifiers for any Android devices or emulators you have running (probably none at the moment).

3. Install IntelliJ Community Edition

  • http://www.jetbrains.com/idea/download/
  • Click "Download Now" for the Community Edition (FREE) on the right side
  • Open the .dmg file
  • Drag the thing to the thing. (technical definition)
  • You can now open IntelliJ from the Applications folder.

4. Configure IntelliJ with the Java and Android SDKs

  • Open IntelliJ
  • View --> Open Module Settings (or F4)
  • Select "SDKs" under "Platform Settings"
  • Click the plus sign and select "Java SDK"
  • Finder should show "Home". Select "Choose" and it should bring in Java 1.6
  • Click the plus sign and select "Android SDK"
  • Navigate and select the android-sdk-macosx folder and select "Choose"
  • If you have installed multiple Android SDK versions, you can choose one here. Since we only installed 4.2, go ahead and click "OK".
  • Note that it is a bit tedious to do this for all Android SDK versions =\

5. Do the OAK Quick Start to get an app checked out:

  • Navigate to a dev/ directory
  • Follow the instructions here: http://willowtreeapps.github.com/OAK/quick-start.html
  • Maven will check out a number of projects and prompt for some setup parameters:
    • groupId: com.demo.android
    • artifactId: demo-android
    • version: [USE DEFAULT]
    • package: [USE DEFAULT]
    • Y: [USE DEFAULT]
  • Output will be BUILD SUCCESS and you should now have a demo-android folder in this directory.

6. Open the created project

  • Open IntelliJ
  • File --> Open... --> pom.xml (from the created project)

7. Set an Android SDK for the project and any other child modules

  • Right-click the main module (the demo-android "folder") and select "Open Module Settings" (or F4)
  • Select "Modules" under "Project Settings" (if not already selected)
  • Choose an Android SDK under the Module SDK dropdown (for example Android 4.2 Platform)
  • Do the same for the ~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0 module

8. Configure an Android Virtual Device (AVD)

  • Open IntelliJ
  • Tools --> Android --> AVD Manager
  • Select the "Device Definitions" tab, select "Galaxy Nexus", and select "Create AVD..."
  • Check off "Use Host GPU" and otherwise use the defaults. Select "OK".
  • Highlight the created AVD and select "Start..."

9. Create a Run Configuration

  • Select the dropdown next to the Play button and select "Edit Configurations..."
  • Click the Plus icon at the top and select "Android Application"
  • Name your module if you like
  • Select the module (there should be only one, it'll be named demo-android)
  • Select the "Show chooser dialog" radio button (this will prompt you to install it on an emulator or attached device)
  • Click OK
  • Click Play.
  • A dialog should pop up allowing you to choose a plugged-in device or launch an emulator.
  • Launch the emulator, and wait for it to load and browse your app in all its glory.
  • Congratulate yourself on having a ListView without having touched a single line of code.

Optional: Ensure the application can be deployed with maven.

  • Open Terminal and navigate to the project directory
  • Execute mvn clean install to compile
  • Exeucte mvn android:deploy to deploy the app to a device or emulator

Other suggestions/options:

  • Use the Dark Theme
    • IntelliJ IDEA --> Preferences... --> Appearance --> Theme: Darcular
    • (Restart)
  • Enable zoom with Cmd + Mouse Wheel
    • IntelliJ IDEA --> Preferences... --> Editor --> Check "Change font size (Zoom) with Command+Mouse Wheel"
  • Disable caret after end of line
    • IntelliJ IDEA --> Preferences... --> Editor --> Uncheck "Allow placement of caret after end of line"
  • Show line numbers
    • IntelliJ IDEA --> Preferences... --> Editor --> Appearance --> Check "Show line numbers"
  • If coming from Eclipse, use Eclipse keybindings
    • IntelliJ IDEA --> Preferences... --> Keymap --> Keymaps: Eclipse
  • Install JSON Formatter Plugin
    • IntelliJ IDEA --> Preferences... --> Plugins
    • Browse repositories, find JSON Formatter, install, restart
  • Install ALL Sdks and such
    • android update sdk --no-ui --obsolete --force
    • Let it chug along.
  • Use the WTA code style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment