square / square/mobile-payments-sdk-react-native
Android: protobuf-java conflicts with Firebase (protobuf-javalite) causing DuplicateClass and VerifyError
@cesar-sosa-hol is already working on this.
Since Jun 26, 2026.
- Dominant language
- TypeScript
- Stars
- 16
- Forks
- 8
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
Description
When using mobile-payments-sdk-react-native alongside Firebase (Firestore/Auth/Crashlytics) on Android, the build fails with DuplicateClass errors and/or the app crashes at runtime with VerifyError.
The root cause is a dependency conflict between the two SDKs:
- Square Mobile Payments SDK (all versions 2.3.0–2.5.0) depends on
com.google.protobuf:protobuf-java(full runtime) - Firebase Android SDKs depend on
com.google.protobuf:protobuf-javalite(lite runtime)
These two protobuf variants have incompatible class hierarchies. For example, com.google.protobuf.Timestamp extends GeneratedMessage in protobuf-java but extends GeneratedMessageLite in protobuf-javalite. Firebase's compiled bytecode contains casts like (GeneratedMessageLite) Timestamp, which fail at runtime with VerifyError when protobuf-java is on the classpath.
There is no Gradle exclusion workaround that resolves this:
- Excluding
protobuf-javafixes the dexDuplicateClassbuild error, but Square SDK may fail if it relies on full-protobuf APIs at runtime. - Excluding
protobuf-javalitecauses a newDuplicateClass(fromprotolite-well-known-types) and thenVerifyErrorat runtime because Firebase's bytecode was compiled againstGeneratedMessageLite, notGeneratedMessage.
Steps to reproduce
- Create a React Native project using
mobile-payments-sdk-react-native - Add Firebase to Android:
@react-native-firebase/app,@react-native-firebase/firestore,@react-native-firebase/auth,@react-native-firebase/crashlytics - Run
./gradlew assembleDebug
Expected behavior
Build succeeds and app runs without crash. Both Square SDK and Firebase coexist on Android.
Actual behavior
Build-time error (DuplicateClass):
DuplicateClass com.google.protobuf.AbstractMessageLite found in modules
protobuf-java-3.25.3.jar (com.google.protobuf:protobuf-java:3.25.3)
protobuf-javalite-3.25.1.jar (com.google.protobuf:protobuf-javalite:3.25.1)
Runtime error if protobuf-java is excluded (VerifyError):
java.lang.VerifyError: Verifier rejected class com.google.firebase.firestore.proto.WriteResponse
because: com.google.protobuf.Timestamp is not instance of
com.google.protobuf.GeneratedMessageLite (declaration of
'com.google.firestore.v1.WriteResponse' appears in
/data/app/.../base.apk)
Environment
mobile-payments-sdk-react-native: 2025.12.1 (native SDK 2.3.1–2.5.0, all affected)@react-native-firebase/app: 21.x- React Native: 0.79.x
- Android: minSdk 28, compileSdk 35
Workaround
Exclude the Square SDK from Android autolinking (react-native.config.js) and provide a no-op JS stub for Android via platform-specific files (.android.ts). This means Square card payments are unavailable on Android.
Request
Please consider migrating the native Android SDK's protobuf dependency from protobuf-java to protobuf-javalite. Firebase and most modern Android libraries use javalite, and it is Google's recommended protobuf variant for Android. This would allow Square SDK and Firebase to coexist without conflicts.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.