InMobi / sdk-sample-code-android

This repository contains InMobi Android SDK sample code for different ad-formats, which publishers can use to incorporate in their apps — Edit
Apache License 2.0
38 stars 43 forks source link

InMobiSdk crashes, if play-services-location is installed #105

Open fornewid opened 1 week ago

fornewid commented 1 week ago

Our company's application is using com.inmobi.monetization:inmobi-ads-kotlin:10.6.2.

We recently updated the Google Play Billing library to version 6.2.1. And com.google.android.gms:play-services-location:19.0.0 is installed by Play Billing library.

After that, InMobiSdk crashes like the following stactraces:

java.lang.IncompatibleClassChangeError: Found class com.google.android.gms.location.FusedLocationProviderClient, but interface was expected (declaration of 'com.google.android.gms.location.FusedLocationProviderClient' appears in /data/internal_app/{our application package}-BumjAcCdfEkBz7mfi7BZbg==/base.apk!classes2.dex)
    at com.inmobi.media.d6.b(LocationInfo.kt:50)
    at com.inmobi.media.zb.h(TokenRequest.kt:42)
    at com.inmobi.sdk.InMobiSdk.getToken(InMobiSdk.kt:21)

But, com.inmobi.monetization:inmobi-ads-kotlin library has no depencency to play-services-location. So I think, InMobiSdk refer FusedLocationProviderClient using reflection.

So please let us know which version of play-services-location we should use.

Please note that the same issue is also registered in the Google AdMob inquiry channel. https://groups.google.com/g/google-admob-ads-sdk/c/JUA7N07ZcAM?pli=1

fornewid commented 1 week ago

Now I understand why.

InMobi SDK has a hidden dependency on play-services-location 21.0.1. And play-services-location can be optionally added by app.

FusedLocationProviderClient is an interface in 21.0.1. FusedLocationProviderClient is a class in 19.0.0.

If add play-services-location 19.0.0 to app, then IncompatibleClassChangeError occurs. And Exception has already been handled inside the LocationInfo.kt file:

But, IncompatibleClassChangeError is an Error. Not Exception. So our application will crash in this case.

Is there a flag to turn off location collection in the InMobi SDK so that LocationInfo doesn't work?

Or would it be possible to handle Throwable instead of Exception?