java Gradle找不到com.google.protobuf

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

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

下面是build.gradle文件:

  1. // Apply the java-library plugin to add support for Java Library
  2. apply plugin: 'java-library'
  3. // In this section you declare where to find the dependencies of your project
  4. repositories {
  5. // Use jcenter for resolving your dependencies.
  6. // You can declare any Maven/Ivy/file repository here.
  7. jcenter()
  8. }
  9. dependencies {
  10. // This dependency is used internally, and not exposed to consumers on their own compile classpath.
  11. implementation 'com.google.protobuf:protobuf-java:3.5.1'
  12. implementation 'com.google.protobuf:protobuf-gradle-plugin:0.8.7'
  13. // Use JUnit test framework
  14. testImplementation 'junit:junit:4.12'
  15. }

有没有少了什么的线索?

8ehkhllq

8ehkhllq1#

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

  1. dependencies {
  2. implementation "androidx.datastore:datastore:1.0.0"
  3. implementation "com.google.protobuf:protobuf-javalite:3.18.0"
  4. }
  5. protobuf {
  6. protoc {
  7. artifact = "com.google.protobuf:protoc:3.18.0"
  8. }
  9. // Generates the java Protobuf-lite code for the Protobufs in this project. See
  10. // https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
  11. // for more information.
  12. generateProtoTasks {
  13. all().each { task ->
  14. task.builtins {
  15. java {
  16. option 'lite'
  17. }
  18. }
  19. }
  20. }
  21. }
展开查看全部

相关问题