Step 1: Verify local.properties file
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# This file should *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
As noted, this is for us to only verify that we have the right Android tools directory specified.
I also have $ANDROID_HOME in my ~/.profile which serves the same purpose
# ANDROID - updated: Oct 17, 2014
Remember to update build-tools to latest stable version, in my case Android Lollipop 5.0. API 21
If you are developing code with multiple people, verify that .gitignore file contains files that are specific only to you.
Step 2: Gradle Project structure with library projects
Step 3: Gradle Wrapper "gradlew" permission to execute
I had to add execute (+x) permissions to my gradlew script
-bash: ./gradlew: Permission denied
$ chmod +x gradlew
Run ./gradlew (.bat)
If you inspect gradle/wrapper/gradle-wrapper.properties you will notice it uses older Gradle jar:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
Welcome to Gradle 1.10.
To run a build, run gradlew <task> ...
To see a list of available tasks, run gradlew tasks
To see a list of command-line options, run gradlew --help
$ more gradle/wrapper/gradle-wrapper.properties#Fri Oct 17 10:58:51 CDT 2014
However updating it to a newer one did not produce correct results, so I left it at original 1.10.
Step: Preventing duplicate dependencies
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;
Make sure that if your Library project has:
then you main App should not have the different version of the same jar.
Build > Clean Project
Step: before writing of a new build script always update Android SDK
Step: Writing example app build.gradleWhile writing Gradle script use Android Studio tips:
The sections listed below are in the same order as in my project/app/build.grade file:
Step: plugin Android or Java?
apply plugin: 'com.android.application'
// build script is not necessary unless you want to provide non-standard configuration
// even if not necessary, I am giving example of other repo in case failure of mavenCentral
// This is Android plugin for Gradle, not actual Gradle 2.1
// classpath 'com.android.tools.build:gradle:0.12.+'
* Include all jars from the lib directory.
compile fileTree(dir: 'libs', include: ['*.jar'])
* You must install or update the Support Repository through the SDK Manager to use this dependency.
* v4 is needed for Theme.AppCompat.Light.DarkActionBar
* Even if NOT recommended I use 19.+ notation, also I am not using 21.+ because of errors:
* No resource found that matches the given name 'android:TextAppearance.Material'.
* even if my SDK Manager is up to date with API 21.
* since support-v7 is included in the libraries project it is not needed here.
// compile 'com.android.support:appcompat-v7:21.0.0'
* The main app depends on LIBRARY ListViewSwipeActivity
* needed only if you have to specify non-standard configuration
* even if not necessary, I am giving example of other repo in case failure of mavenCentral