ProtoBuf 适配 Gradle7.5
gradle-wrapper.properties 配置
distributionUrl= https\: / / services. gradle. org/ distributions/ gradle- 7.5 - bin. zip
Project:build.gradle:
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'com.google.protobuf' version '0.8.19' apply false
}
App:build.gradle:
android {
sourceSets {
main {
proto {
srcDir 'src/main/proto'
include '**/*.proto'
}
}
}
}
dependencies {
implementation "com.google.protobuf:protobuf-java:3.6.1"
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.6.1'
}
generateProtoTasks {
all ( ) . each { task - >
task. builtins {
remove java
}
task. builtins {
java { }
}
}
}
}
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 33 34 35 36 37
ProtoBuf 适配 Gradle8.0
gradle-wrapper.properties 配置
distributionUrl= https\: / / services. gradle. org/ distributions/ gradle- 8.0 - bin. zip
Project:build.gradle:
plugins {
id 'com.android.application' version '8.1.3' apply false
id 'com.android.library' version '8.1.3' apply false
id 'com.google.protobuf' version '0.9.3' apply false
}
App:build.gradle:
android {
sourceSets {
main {
proto {
srcDir 'src/main/proto'
include '**/*.proto'
}
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.21.7'
}
generateProtoTasks {
all ( ) . each { task - >
task. builtins {
remove java
}
task. builtins {
java { }
}
}
}
}
dependencies {
implementation 'com.google.protobuf:protobuf-java:3.21.7'
}
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 33 34 35 36