Reputation: 673
The title pretty much says it all. I would like to create a new Gradle based Android project in IntelliJ IDEA (13 EAP) like I can do in Android Studio.
I've tried creating a new Android Project in IntelliJ but it uses the "old" build system, while creating a new Gradle Project creates a generic java project which doesn't have Android integration at all.
What can I do?
Upvotes: 14
Views: 5981
Reputation: 6847
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')
}
}
Run
> Edit configurations
and add(+
) Groovy run/debug configurationScript 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'
}
Upvotes: 6
Reputation: 7756
Just an update: for IntelliJ IDEA 13.1.0, you can follow this link
As suggested, I just quote the details here
To create a Gradle-based Android project, do one of the following:
If you are going to create a new project: click Create New Project on the Welcome screen or select File | New Project. As a result, the New Project wizard opens. If you are going to add a module to an existing project: open the project you want to add a module to, and select File | New Module. As a result, the New Module wizard opens.
On the first page of the wizard, in the left-hand pane, select Android. In the right-hand part of the page, select Gradle: Android Module. Click Next.
- Specify the JDK and Android SDK to be used, and click Next.
- Specify your Android module settings, and click Next.
- Specify the settings for your Android-Gradle Foreground configuration, and click Next.
- Select an Android application template from the list, and click Next.
- Specify the settings for the selected Android Activity template, and click Next.
- Specify the name and location settings. For more information, see Project Name and Location or Module Name and Location.
- Click Finish.
Upvotes: 5