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-java fixes the dex DuplicateClass build error, but Square SDK may fail if it relies on full-protobuf APIs at runtime.
- Excluding
protobuf-javalite causes a new DuplicateClass (from protolite-well-known-types) and then VerifyError at runtime because Firebase's bytecode was compiled against GeneratedMessageLite, not GeneratedMessage.
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.
Description
When using
mobile-payments-sdk-react-nativealongside Firebase (Firestore/Auth/Crashlytics) on Android, the build fails withDuplicateClasserrors and/or the app crashes at runtime withVerifyError.The root cause is a dependency conflict between the two SDKs:
com.google.protobuf:protobuf-java(full runtime)com.google.protobuf:protobuf-javalite(lite runtime)These two protobuf variants have incompatible class hierarchies. For example,
com.google.protobuf.TimestampextendsGeneratedMessageinprotobuf-javabut extendsGeneratedMessageLiteinprotobuf-javalite. Firebase's compiled bytecode contains casts like(GeneratedMessageLite) Timestamp, which fail at runtime withVerifyErrorwhenprotobuf-javais on the classpath.There is no Gradle exclusion workaround that resolves this:
protobuf-javafixes the dexDuplicateClassbuild error, but Square SDK may fail if it relies on full-protobuf APIs at runtime.protobuf-javalitecauses a newDuplicateClass(fromprotolite-well-known-types) and thenVerifyErrorat runtime because Firebase's bytecode was compiled againstGeneratedMessageLite, notGeneratedMessage.Steps to reproduce
mobile-payments-sdk-react-native@react-native-firebase/app,@react-native-firebase/firestore,@react-native-firebase/auth,@react-native-firebase/crashlytics./gradlew assembleDebugExpected behavior
Build succeeds and app runs without crash. Both Square SDK and Firebase coexist on Android.
Actual behavior
Build-time error (DuplicateClass):
Runtime error if
protobuf-javais excluded (VerifyError):Environment
mobile-payments-sdk-react-native: 2025.12.1 (native SDK 2.3.1–2.5.0, all affected)@react-native-firebase/app: 21.xWorkaround
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-javatoprotobuf-javalite. Firebase and most modern Android libraries usejavalite, and it is Google's recommended protobuf variant for Android. This would allow Square SDK and Firebase to coexist without conflicts.