segmentio / analytics-android

The hassle-free way to add analytics to your Android app.
https://segment.com/docs/sources/mobile/android/
MIT License
377 stars 214 forks source link

Why are you using reflection to get advertising id? #797

Closed RyanNewsom closed 2 years ago

RyanNewsom commented 2 years ago

https://github.com/segmentio/analytics-android/blob/master/analytics/src/main/java/com/segment/analytics/GetAdvertisingIdTask.java#L52-L55

This requires us to add a pro-guard rule to prevent obfuscation so that we can get advertising id. Curious why this is built in this fashion?

wenxi-zeng commented 2 years ago

we are trying to make it more general. as you can see from the code, we have not only google ads id, but also amazon fire. we could have more. the idea is to avoid adding unnecessary dependencies to the sdk, since not everyone take the use of ads id. however, in our new analytics-kotlin library, we segregate ads id task to a plugin, so user decide to import it or not by their choice, and of course, no reflection there. it is encouraged to migrate to the kotlin library, since it is 2x faster with 2x less resources and fully coroutine based.