Flutter+Firebase. Duplicate class error at compile time for android on flutter, protobuf-javalite from cloud_firestore and protobuf-lite from web3auth_flutter

SDK Name: Flutter SDK
Version: 1.0.3

Im using firebase and flutter. On ios, web3auth is integrating fine, but on android emulator, I’m getting a duplicate class error. The torus android sdk that the web3auth flutter package uses is using com.google.protobuf:protobuf-lite:3.0.1 while cloud_firestore flutter package uses com.google.protobuf:protobuf-javalite:3.21.7. These have conflicting class names but I’m not sure the best way to resolve them.

Are other firebase flutter users experiencing this issue? How are people resolving these dependencies and does the web3auth team plan on switching from protobuf-lite to protobuf-javalite?

Screenshot when I try to run my app on android emulator:

When checking the dependency tree on gradle, this is what I’m seeing for cloud_firestore:

And for web3auth:

@shahbaz please have a look

1 Like

Hey @maseh

Could you share your dependencies from your pubspec.yaml file here?

Meantime, can you check whether this issue persists with this example we made with the same combination? examples/flutter/flutter-firebase-example at main · Web3Auth/examples · GitHub

1 Like

I’ve narrowed it down to two dependencies, one is a KYC provider (persona) and the other is firestore (firebase).

Using your example, I can reproduce the error by adding those two dependencies. I get the duplicate class errors for protobuf and for bouncycastle.

If I revert the web3auth flutter sdk to version 1.0.3 (not 1.1.0), the error disappears and everything works.

Here is the error state:

Here is the working state:

Thanks for testing the scenarios @maseh

Let me share this with our Engineering team to find a fix in the latest version.

1 Like

@maseh Add “android.enableJetifier=true” in “gradle.properties” file. It should resolve error.

Hi Gaurav it’s already set to true:

@maseh Updated android security library version which should resolve it. PR(Handle changes for shared prefs wrt android version 12 and above by grvgoel81 · Pull Request #43 · Web3Auth/web3auth-android-sdk · GitHub) is in review. We will release soon.

1 Like

We have released new flutter version v1.1.2

2 Likes

Awesome, thank you Gaurav!!

Hey Gaurav, I see that you’ve updated it on github, any idea when the update will be added to pub?

@maseh Released in pub.dev too.

1 Like

I was also facing the same issue yesterday Duplicate class com.web3auth.core.types.WhiteLabelData found in modules.

I was able to resolve the issue by removing implementation 'com.github.Web3Auth:web3auth-android-sdk:4.0.8' from build.gradle.

I took the reference from here: https://github.com/Web3Auth/web3auth-pnp-examples/blob/main/flutter/flutter-example/android/app/build.gradle

The app is working fine and I am using Custom authentication with JWT token.

Is this the expected?

1 Like