Introduction
Android Studio offers a wealth of plugins for developers, and many developers want to create their own Android Studio plugins.

However:
-
• There are few tutorials online, and the explanations are not detailed enough, making it difficult to quickly complete the development of an Android Studio plugin.
-
• Different versions of the development IDE can lead to significant differences in the process, and most online tutorials are outdated.
This article will guide you step-by-step on how to develop an Android Studio plugin using the latest version of the IDE. It mainly includes:
-
1. Development Environment Setup
-
2. Plugin Development
-
3. Plugin Debugging
-
4. Plugin Packaging
-
5. Plugin Testing
-
6. Plugin Publishing
1. Development Environment Setup
Step 1: Install the Latest Version of IntelliJ IDEA
This guide uses version 2024: IntelliJ IDEA 2024.1.3.
Download link: https://www.jetbrains.com/zh-cn/idea/download/?section=mac Note: Unlike previous versions, there are significant differences in developing plugins in IntelliJ IDEA 2024.

Step 2: Download the Plugin for Creating Plugin Projects
Unlike previous versions, version 2024 requires downloading a plugin (Plugin Devkit) to develop plugins.
You need to restart the IDE after installation.

Step 3: Create a Project Through the Plugin
Select the IDE Plugin on the left and fill in the necessary information.

2. Plugin Development
After the initial preparations, we officially enter the plugin development phase. We will focus on the following three areas:
-
1. build.gradle.kts
-
2. plugin.xml
-
3. Resource files in main
Focus 1: build.gradle.kts
It is very similar to the build.gradle file in Android Studio, and only common configurations need to be explained here (these configurations can be copied directly to your project as needed).
It is important to note that the property localPath in the build configuration cannot be used with version at the same time, as the local Android Studio path already contains version information. Local debugging and online configuration are two different properties; you can copy as needed.

// Language configuration
// Mainly concerned with the versions of intelliJ and kotlin
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.9.24"
id("org.jetbrains.intellij") version "1.17.3"
}
// Plugin dependencies
// Here are some common kotlin dependencies
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
implementation(fileTree(baseDir ="libs"))
}
// Build configuration
// For more official configurations, see: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
// Parameter introduction
// Local debugging configuration: if debugging directly with Android Studio
localPath.set("/Applications/Android Studio.app/Contents") // macOS example path
// Add required dependency plugins for development
// e.g., add Android plugin
plugins.set(listOf("org.jetbrains.android"))
// Online configuration
version.set("2024.1.3") // Represents the version of the IntelliJ IDE used to build this plugin
type.set("IC")
// Final configuration: choose one of the following
// Local debugging configuration: if debugging directly with Android Studio
localPath.set("/Applications/Android Studio.app/Contents") // macOS example path
plugins.set(listOf("org.jetbrains.android")) // Add Android plugin
// Online configuration
version.set("2024.1.3") // Represents the version of the IntelliJ IDE used to build this plugin
type.set("IC")
plugins.set(listOf("org.jetbrains.android"))
}
Focus 2: Plugin.xml
This mainly concerns some information about plugin publishing. Here we focus on related dependencies (which can be copied directly).
<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
<depends>org.jetbrains.kotlin</depends>

Focus 3: Resource Files in Main
-
• Finally, we are about to start the actual plugin content development.
-
• Plugin development is called: Action: Right-click the kotlin folder in main and follow the instructions.


After clicking create, it will:
-
1. Create a new file (named as just filled in), where you can develop your plugin content.
-
2. Action configuration: in plugin.xml
3. Plugin Debugging
Once the plugin development is complete, you can click the top right corner to debug the plugin.

4. Plugin Packaging
Follow the instructions in the image below to obtain a jar package for the plugin.

5. Plugin Testing
-
• Open the plugin configuration in Android Studio, then choose to install the plugin from local (select the previously generated .jar package).
-
• At this point, you can already use it locally.
6. Plugin Publishing
Once remote publishing is complete, other developers can search for your plugin in the application market.
Step one: Log in/register on the JetBrains plugin development platform, then click upload control.
Link: https://plugins.jetbrains.com/developers/intellij-platform

Step two: Upload the jar package you just packaged & fill in relevant information, and wait for approval.

Conclusion
Thus, the explanation of how to develop an Android Studio plugin is complete.
Click to follow, learn one Android knowledge point every day
Finally, a benefit: Learning materials giveaway
-
Benefit: Personally organized “Android Learning Materials” -
Quantity: 10 people -
Participation method: “Click the lower right corner ‘Looking’ and reply with a screenshot to the public account, randomly selected” Click to get promoted and get a raise!