Intellij Idea - Android Studio 插件 - 构建失败

Ism*_*med 1 android intellij-idea intellij-plugin android-studio

从5个月前开始我使用Intellij Idea CE开发一个android studio插件

Android studio最新更新后

Android Studio Arctic Fox | 2020.3.1
Build #AI-203.7717.56.2031.7583922, built on July 26, 2021
Run Code Online (Sandbox Code Playgroud)

我的插件不再工作了

我更新了 Intellij Idea CE 以匹配 android studio 版本,然后当我尝试再次构建我的插件时

构建失败并显示此错误

Execution failed for task ':instrumentCode'.
> Could not resolve all files for configuration ':detachedConfiguration3'.
   > Could not find com.jetbrains.intellij.java:java-compiler-ant-tasks:203.7717.56.2031.7583922.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/jetbrains/intellij/java/java-compiler-ant-tasks/203.7717.56.2031.7583922/java-compiler-ant-tasks-203.7717.56.2031.7583922.pom
       - https://dl.google.com/dl/android/maven2/com/jetbrains/intellij/java/java-compiler-ant-tasks/203.7717.56.2031.7583922/java-compiler-ant-tasks-203.7717.56.2031.7583922.pom
       - https://jcenter.bintray.com/com/jetbrains/intellij/java/java-compiler-ant-tasks/203.7717.56.2031.7583922/java-compiler-ant-tasks-203.7717.56.2031.7583922.pom
 
Run Code Online (Sandbox Code Playgroud)

这是我的build.gradle

plugins {
    id 'org.jetbrains.intellij' version '0.6.4'
    id 'org.jetbrains.kotlin.jvm' version '1.5.21'
}

group 'com.myplugin'
version '1.5.7'


repositories {
    mavenCentral()
    google()
    jcenter()
}


apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'

dependencies {
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21'

}


// See https://github.com/JetBrains/gradle-intellij-plugin/

intellij {
    version = '2020.3.3'
    plugins = ['android']
    localPath 'ANDROID STUDIO PATH'
    updateSinceUntilBuild = false
}
compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
Run Code Online (Sandbox Code Playgroud)

如何修复它。?

小智 7

由于gradle-intellij-plugin原生不支持Android Studio,它不知道本地AS SDK应该使用什么编译器版本,它会尝试使用与AS相同的版本进行编译,而AS不存在。要解决这个问题,您需要使用Instrumenting dsl显式指定特定的编译器版本。

intellij maven 存储库中列出了所有可用版本。就你而言,我认为 203.7717.56 就可以了。

所以配置应该是这样的:

tasks {
  instrumentCode {
    compilerVersion = "203.7707.56"
  }    
}
Run Code Online (Sandbox Code Playgroud)

  • 它将是 `compilerVersion = "203.7717.56"` 但无论如何非常感谢 (3认同)