hedera-protobufs-java
hedera-protobufs-java copied to clipboard
Deploy separate build artifact for Android with protobuf-lite
This package as-is when imported in the Java SDK cannot be used subsequently in an Android project without increasing the minApiVersion to 26 which cuts off about 63% of the market according to https://developer.android.com/about/dashboards
This is because the regular protobuf-java package is not built for Android and uses intrinsics that are too new:
> Transform artifact protobuf-java.jar (com.google.protobuf:protobuf-java:3.10.0) with DexingNoClasspathTransform
AGPBI: {"kind":"error","text":"MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
The official recommendation is to use protobuf-lite which is a separate package with differently named classes and a different protoc invocation: https://github.com/protocolbuffers/protobuf/blob/master/java/lite.md
We can switch this out with profiles and tag the Android configuration with a android classifier, then build and deploy both the full Java version with no classifier and a lightweight Android version with the android classifier:
- https://maven.apache.org/guides/introduction/introduction-to-profiles.html
- https://stackoverflow.com/a/3094466
- https://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html
(We can then use the same approach to switch which version of the hedera-protobuf package we use in the Java SDK.)
Is still needed? Does it affect anything if we do it on if not?