- Create an android project
- Create an empty file `build.gradle' in the root of your project
- Add to the file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 18
buildToolsVersion "19"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
- Menu
Run
> Edit configurations
and add(+
) Groovy run/debug configuration
- Fill script path to the previously created file 'build.gradle'
- Fill
Script parameters
with desirable task( e.g. installDebug
or assemble
)
To add adb
shell command you may add new task to this script. Sample:
task launchDefaultActivity(type:Exec){
commandLine './adb', 'shell', 'am', 'start', '-c', 'android.intent.category.LAUNCHER', '-n', 'com.example.AndroidGradle/.LaunchActivity'
}