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 falseid 'com.android.library' version '7.4.2' apply falseid '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 {}}}}
}
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 falseid 'com.android.library' version '8.1.3' apply falseid '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'
}