Intellij Idea - Android Studio 插件 - 构建失败
Intellij Idea - Android Studio Plugin - Build Failed
从 5 个月前开始我使用 Intellij Idea CE 开发了一个 android studio plugin
但是
在 Android studio 最新更新后
Android Studio Arctic Fox | 2020.3.1
Build #AI-203.7717.56.2031.7583922, built on July 26, 2021
我的插件不能用了
我更新了 Intellij Idea CE 以匹配 android 工作室版本,然后当我再次尝试构建我的插件时
构建失败并显示此错误
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
这是我的 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"
}
如何解决??
由于 gradle-intellij-plugin 本身不支持 Android Studio,它不知道本地 AS SDK 应该使用什么编译器版本,它会尝试使用与 AS 相同的版本,不存在。要解决此问题,您需要使用 instrumenting dsl.
明确指定特定的编译器版本
intellij maven repository 中列出了所有可用版本。对于你的情况,我认为 203.7717.56 就可以了。
所以配置应该是这样的:
tasks {
instrumentCode {
compilerVersion = "203.7707.56"
}
}
从 5 个月前开始我使用 Intellij Idea CE 开发了一个 android studio plugin
但是
在 Android studio 最新更新后
Android Studio Arctic Fox | 2020.3.1
Build #AI-203.7717.56.2031.7583922, built on July 26, 2021
我的插件不能用了
我更新了 Intellij Idea CE 以匹配 android 工作室版本,然后当我再次尝试构建我的插件时
构建失败并显示此错误
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
这是我的 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"
}
如何解决??
由于 gradle-intellij-plugin 本身不支持 Android Studio,它不知道本地 AS SDK 应该使用什么编译器版本,它会尝试使用与 AS 相同的版本,不存在。要解决此问题,您需要使用 instrumenting dsl.
明确指定特定的编译器版本intellij maven repository 中列出了所有可用版本。对于你的情况,我认为 203.7717.56 就可以了。
所以配置应该是这样的:
tasks {
instrumentCode {
compilerVersion = "203.7707.56"
}
}