Skip to content

Instantly share code, notes, and snippets.

  • Save ahsanu123/1b100962f6ef509b55429dfe3a19275c to your computer and use it in GitHub Desktop.
Save ahsanu123/1b100962f6ef509b55429dfe3a19275c to your computer and use it in GitHub Desktop.
Getting Started: Android Development with Gradle (without Android Studio)

Getting Started: Android Development with Gradle (without Android Studio)

Install JDK

Open Terminal. Type javac -version and check your current JDK version. If you seem to have javac 1.7.* JDK version, you can skip this section.

  • Open Termianl.
  • Type sudo apt-get install openjdk-7-jdk.

Download Android SDK (standalone tools)

Download the standalone SDK tools from official website.

Tip: I renamed my SDK tools directory to "sdk" and put it in to ~/dev/android/.

Add SDK Packages

  • Open Terminal.
  • Navigate to .../sdk-directory/tools/.
  • Run ./android sdk.
  • Add necessary SDK packages.

Set up PATH Environment variable

Open ~/.profile or ~/.bashrc in your text editor and add following lines.

export ANDROID_HOME=~/location/to/your/android/sdk
export PATH=$PATH:$ANDROID_HOME/tools/
export PATH=$PATH:$ANDROID_HOME/platform-tools/

Create Project

This will create the project with gradle.

android create project -p /location/to/MyProject -a MainActivity -k com.domain.myproject -t <target-id> -g -v 0.12.+

<target-id>: Type android list targets in Terminal to get all available sdks.

Build with Gradle

./gradlew build

Install Application to Device

./gradlew installDebug

Still having issues?
Open build.gradle and see if your gradle version (type ./gradlew --version in Terminal) is compatible with com.android.tools.build:gradle version. Read more

Or drop me a message @ talhashraf@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment