codelab-android-datastore icon indicating copy to clipboard operation
codelab-android-datastore copied to clipboard

Could not get unknown property 'source' for generate-proto-generateDebugProto of type

Open TinaT2 opened this issue 4 months ago • 0 comments

These are 2 errors that I've faced on Working with Proto DataStore: Could not get unknown property 'source' for generate-proto-generateDebugProto of type and error: Unresolved reference: protoc

On gradle-8.11.1 and kotlin-gradle.

Here is the resolve:

In build.gradle instead of previous protobuf version:

protobuf {
     protoc {
     //the version here should be the same as what you have in your app build.gradle
        artifact = "com.google.protobuf:protoc:3.18.0"
    }

    generateProtoTasks {
        all().configureEach {
            builtins {
                create("java") {
                    option("lite")
                }
            }
        }
    }
}
java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

And in build.gradle project level:

plugins {
//...
    id("com.google.protobuf") version "0.9.5" apply false 
}

The rest remains the same.

TinaT2 avatar Jun 25 '25 12:06 TinaT2