Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Android project to use Gradle Script Kotlin

I would like to convert build.gradle files in my Android projects from Groovy to Kotlin using Gradle Script Kotlin. Preferably I'd like all of them in Kotlin, but if there are some limitations then as much as possible.

Lets assume I have just an empty project, freshly created from an Android Studio "New application" template (minSdkVersion 15, using AppCompat if that matters). What steps do I need to take for such project to convert it to Gradle Script Kotlin.

I hope this should be a great starting point for me (and everybody else) and I can can handle converting any custom logic I have on my own.

like image 550
Marcin Koziński Avatar asked Jun 05 '16 09:06

Marcin Koziński


People also ask

How do I convert a project to Gradle?

iml files inside your project. Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.

Does Gradle work with Kotlin?

Gradle is a build system that is very commonly used in the Java, Android, and other ecosystems. It is the default choice for Kotlin/Native and Multiplatform when it comes to build systems.


1 Answers

there's already an hello-android example which descibe how to do it.

Check: https://github.com/gradle/gradle-script-kotlin/tree/master/samples/hello-android

Note that:

It has been tested against Android Studio 2.2 Preview 6 with the latest Kotlin plugin from the EAP 1.1 channel.

Read also: https://github.com/gradle/gradle-script-kotlin/issues/2

Hope it will help

like image 113
piotrek1543 Avatar answered Sep 28 '22 05:09

piotrek1543