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?
Convert a regular project into a Gradle project Open your project in IntelliJ IDEA. In the Project tool window, right-click the name of your project and select New | File. In the dialog that opens enter build. gradle and click OK.
Create a new Kotlin/Native project in IntelliJ IDEA In IntelliJ IDEA, select File | New | Project. In the panel on the left, select Kotlin Multiplatform. Enter a project name, select Native Application as the project template, and click Next. By default, your project will use Gradle with Kotlin DSL as the build system.
From the main menu, select Run | Edit Configurations to open the run/debug configuration for your project. icon. In the list that opens, select Run Gradle task. In the Select Gradle Task dialog, specify the project and the task that you want to execute before launching the project.
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'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With