BranchMetrics / sdk-release

TUNE iOS, Android, and Windows native SDKs
https://developers.tune.com/sdk/quick-starts/
GNU General Public License v3.0
56 stars 46 forks source link

Android SDK 6.1.1: App version is 0 when using custom package name #47

Open Dir9119 opened 5 years ago

Dir9119 commented 5 years ago

We have one app (let it be com.example.app) for both Amazon and Google stores, but to have separate analytics for them on Tune website, we pass different package names in calls to Tune.init (as described here: https://tune.docs.branch.io/sdk/creating-unique-package-names/#code-platform-android): com.example.app for Google store and com.example.appamazon for Amazon. Before SDK version 6.0.0 everything worked fine, but now all analytics from Amazon version of the app are displayed with "app_version" = 0.

After investigating your code, it seems that the problem is in this line: https://github.com/BranchMetrics/sdk-release/blob/master/sdk-android/TuneMarketingConsoleSDK/src/main/java/com/tune/TuneParameters.java#L150 SDK versions prior to 6.0.0 used real package name (Context.getPackageName) to query the system about app's version, but now custom package name is used. In our case, Google store version of the app works fine, because its custom package name is the same as the real package name (com.example.app), but on Amazon the system cannot find a package named com.example.appamazon and thus appVersion is set to 0.