Android Proto数据存储区:未能获取类型为... DefaultSourceDirectorySet的generate-proto-generateProductionDebugProto的未知属性“source”

oxf4rvwz  于 2023-08-01  发布在  Android
关注(0)|答案(1)|浏览(150)

根据Proto DataStore codelab,在构建项目时出现异常
安卓Studio长颈鹿2022.3.1
FAILURE:生成失败,出现异常。

  • 哪里出错了:配置项目“:app”时出现问题。
    无法获取org. gradle. api. internal. file. DefaultSourceDirectorySet类型的generate-proto-generateProductionDebugProto的未知属性“source”。
tkclm6bt

tkclm6bt1#

更新到以下代码

plugins {
   ...
   id "com.google.protobuf" version "0.9.4"
}

字符串
和依赖关系

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.8.0'
    }
    generateProtoTasks {
        all().configureEach { task ->
            task.builtins {
                java {
                    option "lite"
                }
            }
        }
    }
}

相关问题