Android Kotlin 导入 Protobuf
2022-10-25 14:34 CST
project build.gradle
1
2
3
plugins {
id "com.google.protobuf" version "0.9.1" apply false
}
module build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
android {
sourceSets {
main {
proto {
srcDir '../../protos'
}
}
}
}
dependencies {
implementation 'com.google.protobuf:protobuf-kotlin-lite:3.21.8'
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.21.8'
}
generateProtoTasks {
all().each { task ->
task.builtins {
kotlin {
option 'lite'
}
java {
option 'lite'
}
}
}
}
}
参考代码
https://github.com/google/protobuf-gradle-plugin
Android Kotlin 导入 Protobuf by mkckr0 is licensed under CC BY-NC-ND 4.0