Proto datastore jetpack compose - gradle dependencies exception
G

3

17

I followed this codelab from the android developer platform: https://developer.android.com/codelabs/android-proto-datastore#4

Added the same exact dependencies as shown in the codelab and I get the following gradle exception when trying to sync

A problem occurred configuring project ':app'.

Could not get unknown property 'source' for generate-proto-generateDebugProto of type org.gradle.api.internal.file.DefaultSourceDirectorySet.
  at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:125)
  at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'source' for generate-proto-generateDebugProto of type org.gradle.api.internal.file.DefaultSourceDirectorySet.
  at com.google.protobuf.gradle.ProtobufPlugin$_linkGenerateProtoTasksToSourceCompile_closure25$_closure39.doCall(ProtobufPlugin.groovy:472)
  at com.google.protobuf.gradle.ProtobufPlugin$_linkGenerateProtoTasksToSourceCompile_closure25.doCall(ProtobufPlugin.groovy:469)
  at com.google.protobuf.gradle.ProtobufPlugin.linkGenerateProtoTasksToSourceCompile(ProtobufPlugin.groovy:468)
  at com.google.protobuf.gradle.ProtobufPlugin$_doApply_closure5.doCall(ProtobufPlugin.groovy:153)
  at jdk.proxy1/jdk.proxy1.$Proxy56.afterEvaluate(Unknown Source)
  at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:125)
  at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)

I have no idea what the issue could be, tried to upgrade the versions shown in the codelab, looked up the issue everywhere, but can't seem to find anyone that experienced the same thing. Any idea?

Glynis answered 4/5, 2023 at 15:52 Comment(1)
I also get the same errorVern
G
35

I had to use the 0.9.1 version of protobuf

plugins {
    id "com.google.protobuf" version "0.9.1"
}
Glynis answered 5/5, 2023 at 8:42 Comment(2)
That didn't help at all for me.Sutler
plugins{ id("com.google.protobuf") version "0.9.1"} protobuf { protoc { artifact = "com.google.protobuf:protoc:3.21.7" } generateProtoTasks { all().forEach { task -> task.builtins { java { "lite" } } } } } --working for me, built successfullySullivan
D
5

The configuration below worked for me.

At module's build.gradle file:

plugins {
    ...
    id "com.google.protobuf" version "0.9.1" 
}
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.21.7"
}

generateProtoTasks {
    all().each { task ->
        task.builtins {
            java {
                option 'lite'
            }
        }
    }
}
}
Dimitris answered 3/9, 2023 at 3:31 Comment(1)
This was the solution for me as well. Thank you very much!Markmarkdown
S
0
plugins { 
     id("com.google.protobuf") version "0.9.1"
}

....

protobuf {
        protoc {
            artifact = "com.google.protobuf:protoc:3.21.7"
        }
    
        generateProtoTasks {
            all().forEach { task ->
                task.builtins {
                    java {
                        "lite"
                    }
                }
            }
        }
    }

Try to build. Newer version of ProtoBuf

Sullivan answered 29/9, 2023 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.