4

I want to stop showing ads if the apk is sideloaded version i.e. if it is not installed from play store. So I did this by:

String installer = getPackageManager().getInstallerPackageName(
    "com.example.myapp");

if (installer == null) {
    // app was illegally downloaded from unknown source. 
    // dear user, please re-install it from market
} 
else if(installer.equals("com.android.vending") {
    // app was installed legally
    
}

Now in one stack overflow answer (link): https://stackoverflow.com/a/36299631/12182265

I found that: The installer packagename can change in the future. For example, the installer package name use to be "com.google.android.feedback" (see here) and now it is "com.android.vending".

So I did some search and I found:

GooglePlayServicesUtilLight.GOOGLE_PLAY_STORE_PACKAGE

constant.

So instead of checking hardcoding value i.e. "com.android.vending" can I use GooglePlayServicesUtilLight.GOOGLE_PLAY_STORE_PACKAGE? Will below code work?

String installer = getPackageManager().getInstallerPackageName(
"com.example.myapp");

if (installer == null) {
    // app was illegally downloaded from unknown source. 
    // dear user, please re-install it from market
} 
else if(installer.equals(GooglePlayServicesUtilLight.GOOGLE_PLAY_STORE_PACKAGE)) {
    // app was installed legally

}

Why I don't want to show ads in sideloaded apk?

Answer: Currently I have app on play store which I made not available in 10 countries. So I have doubt that there ares some users from those 10 countries who installed sideloaded version of it from third party sites which I cannot control. And they clicked on banner ads in my app which resulted ad serving limit placed on my admob account. Am I correct? Or sideloading will not be the cause of ad serving limit?

11738472
  • 184
  • 3
  • 22
Chaitanya Karmarkar
  • 1,425
  • 2
  • 7
  • 18
  • a lot of apps are published on the unsupported store such Hauwei AppGallery and the AdMob ads work on them normally, I'm facing the ad serving limit issue since 02/02/2021, did you find any solution? – Mouaad Abdelghafour AITALI May 06 '21 at 18:44
  • 2
    I deleted all my previous ad units and created new one. And then I used above code and currently not showing any ads if apk is not installed from play store. And one month since then, there is no any ad limit in my admob account. – Chaitanya Karmarkar May 11 '21 at 06:03
  • thank you, but why there's a lot of apps exist on e.g. APKPURE, and AdMob works on them! – Mouaad Abdelghafour AITALI May 11 '21 at 15:41
  • 2
    Yes, you are correct. But I solved issue this way and it worked for me. – Chaitanya Karmarkar May 12 '21 at 12:26
  • I want to update some info. I just read something about facebook ads are not filling on this page, and one of the reasons is App not downloaded from Google Play Store or App Store. So facebook only respond to requests that come from apps downloaded from the Google Play Store or the iOS App Store. So I think there may be a same thing in case of AdMob? Hence sideloaded app users may cause problem?.:https://www.facebook.com/business/help/1673395492911956 – Chaitanya Karmarkar Jun 14 '21 at 06:33
  • Man you are totally right. I have the same issue and solved with ur solution – Abanoub Istfanous Sep 17 '22 at 08:35
  • Yep I didn't faced that issue again in last 18 months. – Chaitanya Karmarkar Sep 20 '22 at 04:42

0 Answers0