Reputation: 703
Every example I can find of configuring build.gradle to compile protobufs uses the "lite" version and looks something like this:
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.6.0'
}
plugins {
javalite {
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
javalite { }
}
}
}
}
dependencies {
implementation 'com.google.protobuf:protobuf-java:3.6.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Note the "javalite". This results in generated java files that use MessageLite, but I need the full Message class.
How do I change this so that it does not generate the "lite" version?
Upvotes: 3
Views: 1710
Reputation: 703
Found the solution:
1) Remove this:
plugins {
javalite {
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
}
}
2) Remove this:
task.plugins {
javalite { }
}
3) Change the task.builtins section to this:
task.builtins {
java { }
}
It will now generate the full featured protobuffs.
Upvotes: 3