[英]Failed to apply plugin 'com.google.protobuf'
我正在嘗試對插件的構建腳本中的錯誤進行故障排除。 我可以從 IntelliJ IDEA 內部運行它,但是當我嘗試從命令行構建時出現異常。
我已經能夠將構建腳本減少到最低限度,如下所示:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.6'
}
}
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.12'
id "maven"
id "de.undercouch.download" version "3.2.0"
id "com.google.protobuf" version "0.8.6"
id "idea"
}
當我嘗試使用此腳本執行構建時,出現以下錯誤:
$ gradle buildPlugin
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/erikengheim/Development/Java/experiment/build.gradle' line: 17
* What went wrong:
An exception occurred applying plugin request [id: 'com.google.protobuf', version: '0.8.6']
> Failed to apply plugin 'com.google.protobuf'.
> Could not create an instance of type com.google.protobuf.gradle.ProtobufSourceDirectorySet.
> 'void org.gradle.api.internal.file.DefaultSourceDirectorySet.<init>(java.lang.String, java.lang.String, org.gradle.api.internal.file.FileResolver, org.gradle.api.internal.file.collections.DirectoryFileTreeFactory)'
如果我只注釋掉該行,我可以讓所有這些工作:
id "com.google.protobuf" version "0.8.6"
我對Gradle或Java不是很熟悉,所以我不知道如何解釋異常的堆棧回溯。
您應該使用protobuf-gradle-plugin
的最新版本,即0.8.13
。 它至少需要 Gradle 5.6 和 Java 8。
更新您的構建腳本:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.13'
}
}
和這一行:
id "com.google.protobuf" version "0.8.13"
根構建.gradle.kts
buildscript {
repositories {
mavenLocal()
google()
mavenCentral()
maven(uri("https://jitpack.io"))
}
dependencies {
//...
classpath("com.google.protobuf:protobuf-gradle-plugin:0.8.18")
}
}
應用程序
plugins {
id("com.android.library")
id("kotlin-android")
kotlin("kapt")
id("kotlin-parcelize")
kotlin("plugin.serialization")
id("com.google.protobuf") //remove version
}
刪除版本
id "com.google.protobuf"
或 Kotlin DSL
id("com.google.protobuf")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.