Google Ads x Google Analytics duplicated classes (com/google/android/gms/internal/zzlu, etc.)

Hi,

I’m using Google Ads and Google Analytics im a project and the build is not working. I receive the error:

Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzlu;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzlv;

And, in fact, the classes are duplicated in two aar:

find . -name ‘*.jar’ -exec grep -Hlsi zzlu {} ;
./Temp/StagingArea/android-libraries/play-services-ads-9.8.0/libs/classes.jar
./Temp/StagingArea/android-libraries/play-services-analytics-impl-9.4.0/libs/classes.jar

I disabled “play-services-analytics-impl-9.4.0” in the inspector for Android Platform and I can build, but, of course, lost the Analytics functionality. Somebody know how to solve this problem?

Are you sure that this is the right source for the duplicated classes?
In any case - it looks like you’re mixing libraries from 2 different versions (9.4.0 and 9.8.0).

My suggestions to you:

  • Make sure that these .aar libraries are indeed the ones that contain the duplicate classes.
  • Try to use the same version for all google play service libraries (e.g: 9.8.0).
  • If everything else fails, I’d like to note that I offer my professional services for solving this particular kind of errors: Fix your unity build errors on android by Lysergide | Fiverr

Hi Lior,

Yes, I’m pretty sure that these are the source of the duplicated classes. I copied the correct aar from ANDROID_SDK/extras/google/m2repository/com/google/android/gms/play-services-analytics-impl/9.8.0/play-services-analytics-impl-9.8.0.aar but for some reason Unity put back the 9.4.0 version of the aar.

As a workaround I downloaded the jar android-google-play-services-analytics-impl/libs/google-play-services-analytics-impl.jar at master · dandar3/android-google-play-services-analytics-impl · GitHub and now I can build and get the right functionality, but I’m sure this is not the best solution.

I’ll try to understand better this issue and, if I get stuck I’ll contact you.

Many plugins use the google play “resolver” – a library that automatically will fetch any required google play services libraries into your project.

The issue is, that since this resolver runs automatically, its operation may actually conflict with other plugins in your project that already contain their own copies of google play services.

So, for example, in your case, you already have the library versioned 9.8.0, and the resolver keeps adding back 9.4.0 which causes a conflict (this is just speculation but sounds reasonable).