mParticle / mparticle-flutter-sdk

A Flutter plugin that gives developers an API to implement mParticle on Flutter. This supports publishing a Flutter plugin to iOS, Android, and Web.
Apache License 2.0
4 stars 8 forks source link

Not sending/receiving android_advertising_id on release mode #40

Closed Ashkan-Oliaie closed 1 year ago

Ashkan-Oliaie commented 1 year ago

Hi, We've been trying to integrate mParticle and include android_advertising_id. We faced the issue that can not send/receive android_advertising_id, though it's working fine on debug/dev mode, when building a release apk, it's not there.

We ensured adding the dependencies and permissions But we are facing these issue :

Failed to collect Advertising ID, be sure to add Google Play services (com.google.android.gms:play-services-ads) or Amazon Ads (com.amazon.android:mobile-ads) to your app's dependencies.

MicrosoftTeams-image (17)

any idea what might be the issue ?

sefidgaran commented 1 year ago

Hello

I can reproduce the issue in release for the example provided in this mParticle Flutter SDK. Tested on Android 13 real device (Samsung Galaxy S20+).

When we build APK in release using command: flutter build apk --release Android advertising id will not be collected and sent for some reason but its working fine in debug/dev.

mParticle SDK team please investigate.

Thanks

iguzman23 commented 1 year ago

Hi!

I am from the mParticle TSE team, we have a ZD ticket raised for this issue.

We are trying to reproduce the issue in order to get more data to fill a bug for our engineering team.

We will keep you posted in the ZD ticket with any relevant information we learn of.

Regards,

samdozor commented 1 year ago

Hi @sefidgaran question for you - are you including com.google.android.gms:play-services-ads-identifier as a dependency in your build? also are you using proguard/minification? in your production build?

sefidgaran commented 1 year ago

In case if you are not aware, we received an update from mParticle team through ticket system mentioned earlier that mParticle reproduced the issue.

samdozor commented 1 year ago

yep I am aware. Engineering investigated the bug that the TSE team logged - and the issue is that the default proguard/minify rules for either play services or that's generated by gradle no longer includes rules to avoid minifying the play services library.

We use reflection to grab the Google Ad ID, and so when you obfuscate the play services code in your app (you likely only have this enabled for your production builds), and it renames the play services classes, it breaks.

we are going to add an update to our SDK to add these rules to our consumer-proguard file which your app will then inherit. That said - you can work around this right now with any SDK version by avoiding the minification of the play services AdvertisingIdClient.

For example - add this to your Flutter app's proguard file:

-keep class com.google.android.gms.ads.identifier.** { *; }
sefidgaran commented 1 year ago

Hi @samdozor After I investigated on this issue looks like the issue is fixed in mParticle end and we are receiving Android AD ID in production without any changes in our code/proguard rules. anyway thanks for your comments.

@Ashkan-Oliaie please confirm. Thanks

Ashkan-Oliaie commented 1 year ago

I can confirm that the issue is fixed on mParticle side. We're receiving android_advertising_id. Thanks everyone

samdozor commented 1 year ago

@sefidgaran @Ashkan-Oliaie happy to hear it's resolved - though it's odd because we didn't make any update. Keep the above recommendation in mind if the issue presents itself again in the future.