java Gradle找不到com.google.protobuf

evrscar2  于 2023-09-29  发布在  Java
关注(0)|答案(1)|浏览(320)

我正在尝试使用gradle编译一个protobuf项目。但是,我在protobuf生成的java文件中得到以下错误:

下面是build.gradle文件:

// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.protobuf:protobuf-java:3.5.1'
    implementation 'com.google.protobuf:protobuf-gradle-plugin:0.8.7'
    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
}

有没有少了什么的线索?

8ehkhllq

8ehkhllq1#

对于我更新这行
artifact =“com.google.protobuf:protoc:3.18.0”
与此行具有相同的版本号解决了问题。
实现“com.google.protobuf:protobuf-javalite:3.18.0”

dependencies {
    implementation  "androidx.datastore:datastore:1.0.0"
    implementation  "com.google.protobuf:protobuf-javalite:3.18.0"
}

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.18.0"
    }

    // Generates the java Protobuf-lite code for the Protobufs in this project. See
    // https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
    // for more information.
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option 'lite'
                }
            }
        }
    }
}

相关问题