Gradle Plugin Tutorial for Android: Getting Started
Jun 7 2021
, Kotlin 1.4, Android 5.0, Android Studio 4.1Kotlin 1.4, Android 5.0, Android Studio 4.1
Learn how to create a Gradle plugin within your existing Android app, or as a standalone project that you can publish and use in any Android project.
By Bhavesh Misri.
After adding the code, sync the Gradle changes again. This task will publish your plugin to your desired location. You can execute the task by either clicking on the green play button next to the task or executing the command ./gradlew -q uploadArchives in the terminal. Build and run and you’ll see the plugin directory in your desired location.
Next, you’ll use it in your Android Studio project. Fire up the ProjectTracker project again, and open the project-level build.gradle file. Inside repositories within the buildscript block, add:
Now, your project has access to the plugin files. To apply the plugin, open the module-level build.gradle file and add the following lines at the bottom of your Gradle file:
If this tutorial helped you and you ended up creating an awesome plugin that you want to share with everyone, you can publish it on the Gradle plugin portal by following the official documentation on Publishing Plugins to the Gradle Plugin Portal.
We hope you enjoyed this tutorial. If you have any questions or comments, please join the forum discussion below!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.