Search code examples
android-studiointellij-plugin

creating Android Studio plugin using IntelliJ `runIde` can not be invoked


Working on creating an android studio plugin using IntelliJ .

Following the guide https://plugins.jetbrains.com/docs/intellij/gradle-build-system.html using the Gradle and the android studio plugin guide https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-pluginxml-file

After created the project using the wizard and added the section runIde.
I am getting an error.
Expression 'runIde' cannot be invoked as a function. The function 'invoke()' is not found.

here is the build.gradel.kts.

plugins {
    id("java")
    id("org.jetbrains.kotlin.jvm") version "1.6.20"
    id("org.jetbrains.intellij") version "1.5.2"
}

group = "com.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
intellij {
    version.set("212.5712.43")
    type.set("IC") // Target IDE Platform

    plugins.set(listOf("android"))
}

runIde {
    // Absolute path to installed target 3.5 Android Studio to use as
    // IDE Development Instance (the "Contents" directory is macOS specific):
    ideDir.set(file("/Applications/Android Studio.app/Contents"))
}

tasks {
    // Set the JVM compatibility versions
    withType<JavaCompile> {
        sourceCompatibility = "11"
        targetCompatibility = "11"
    }
    withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions.jvmTarget = "11"
    }

    patchPluginXml {
        sinceBuild.set("212")
        untilBuild.set("222.*")
    }

    signPlugin {
        certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
        privateKey.set(System.getenv("PRIVATE_KEY"))
        password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
    }

    publishPlugin {
        token.set(System.getenv("PUBLISH_TOKEN"))
    }
}

OS.
macOS Monterey version 12.4.

The IntelliJ info.
IntelliJ IDEA 2022.1.1 (Community Edition).
Build #IC-221.5591.52, built on May 11, 2022.

Android Studio info.
Android Studio Chipmunk|2021.2.1.
Build#AI-212.5712.43.2112.8512546, Build on April 29, 2022.


Solution

  • Your runIde needs to be in the tasks block:

    tasks {
        runIde {
            // Absolute path to installed target 3.5 Android Studio to use as
            // IDE Development Instance (the "Contents" directory is macOS specific):
            ideDir.set(file("/Applications/Android Studio.app/Contents"))
        }
    }