My question is pretty simple: is there any way for Google Analytics to be disabled automatically when the application is signed with the debug certificate? Means it should be active only in release version. Thank you in advance.
If you're an administrator of Google accounts for an organization, you can control who uses Google Analytics from their account. Just turn Analytics on or off for those people in your Admin console.
If you're using ADT 17 and above, you can utilize the BuildConfig class:
if(BuildConfig.DEBUG) {
GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(getApplicationContext());
googleAnalytics.setAppOptOut(true);
}
The BuildConfig class is automatically generated like R.java is. It only contains the DEBUG boolean, which is set to true by default, and to false when you export an apk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With