I developed a plugin. And I’m trying to install it on Android Studio. I get this IDE error:
java.lang.NoClassDefFoundError: com/android/tools/idea/logcat/AndroidLogcatService
This is the depends tags in my plugin.xml file:
<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.androidstudio</depends>
<depends>org.jetbrains.android</depends>
File build.gradle.kts
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.7.20"
id("org.jetbrains.intellij") version "1.12.0"
}
intellij {
version.set("2022.3.3")
type.set("IC") // Target IDE Platform
updateSinceUntilBuild.set(false)
plugins.set(listOf(/* Plugin Dependencies */
"android",
"gradle"
))
}
runIde {
ideDir.set(file("/Applications/Android Studio.app/Contents"))
}
Important error lines
java.lang.NoClassDefFoundError: com/android/tools/idea/logcat/AndroidLogcatService
Caused by: java.lang.ClassNotFoundException: com.android.tools.idea.logcat.AndroidLogcatService PluginClassLoader(plugin=PluginDescriptor(name=PlugiTest06, id=com.example.PlugiTest06, descriptorPath=plugin.xml, path=~/Library/Application Support/Google/AndroidStudio2022.3/plugins/PluginTest06, version=1.0-SNAPSHOT, package=null, isBundled=false), packagePrefix=null, instanceId=125, state=active)
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:217)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
I don’t know why I get this error and I’m using the same version for IntelliJ IDEA and Android Studio.
I’m guessing we need to add another depend tag which gives us access to the AndroidLogcatService class or add something to Gradle which provide the same purpose for me.
The error you're encountering suggests a
NoClassDefFoundErrorforcom/android/tools/idea/logcat/AndroidLogcatService. This usually occurs when your plugin is trying to use a class that is not available during runtime.Firstly, ensure that you are using the correct versions for the dependencies. Make sure that the versions specified in your
plugin.xmlandbuild.gradle.ktsfiles are compatible with each other.Next, since your plugin relies on Android-related classes, you might need to add a dependency on the Android Gradle plugin in your
build.gradle.ktsfile. Update yourpluginsblock to include the Android Gradle plugin like this:kotlin
Make sure to adjust the version number according to the version of the Android Gradle plugin you want to use.
If the issue persists, you may need to look into the classpath and dependencies more closely. Sometimes, conflicts or missing dependencies can cause such runtime errors. You can check the dependencies and their versions using the following Gradle command:
This command will display the dependency tree, and you can analyze if there are any conflicts or missing dependencies related to Android.
Additionally, ensure that your plugin is compatible with the specific version of Android Studio you are using. Sometimes, updating or downgrading your plugin or Android Studio version can resolve compatibility issues.
If none of these solutions work, consider reaching out to the Android Studio or IntelliJ IDEA plugin development communities for more specific assistance. They may be able to provide insights or solutions based on their experience with plugin development for these IDEs.