Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proto datastore jetpack compose - gradle dependencies exception

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?

like image 428
Giuliopime Avatar asked Sep 14 '25 15:09

Giuliopime


2 Answers

I had to use the 0.9.1 version of protobuf

plugins {
    id "com.google.protobuf" version "0.9.1"
}
like image 82
Giuliopime Avatar answered Sep 16 '25 08:09

Giuliopime


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'
            }
        }
    }
}
}
like image 40
Jayesh Nair Avatar answered Sep 16 '25 07:09

Jayesh Nair