PiracyChecker fails to check whether the app is installed from Google Play Store
Asked Answered
I

1

6

I'm using 'com.github.javiersantos:PiracyChecker:1.2.3' because my app is not yet integrates AndroidX.

I have numerous reports from user reviews in my app's Google Play page that they have installed the app from the Google Play Store, yet they getting the piracy warning message.

Here are some examples:

enter image description here

Also got a user report via email:

enter image description here

My app have 4k reviews and only 3 of them are like this, but I don't know the exact user count because there could be users who don't comment about this issue.

What is going on?

I use it like this:

    public static void showPiracyActivityIfNeeded(final Activity activity) {
    if (!BuildConfig.DEBUG) {
        //Releaseb build, piracy check.
        new PiracyChecker(activity)
                .enableInstallerId(InstallerID.GOOGLE_PLAY)
                .callback(new PiracyCheckerCallback() {
                    @Override
                    public void allow() {
                    }

                    @Override
                    public void dontAllow(@NonNull PiracyCheckerError piracyCheckerError, @Nullable PirateApp pirateApp) {
                        Intent intent = new Intent(activity, PiracyWarningActivity.class);
                        activity.startActivity(intent);
                        activity.finish();
                    }
                })
                .start();
    }
}

Thanks in advance.

Iow answered 22/11, 2019 at 11:15 Comment(2)
According to author of library: "This seems to happen when the device has just booted. ..PiracyChecker checks before Google Play Services has actually started."Runkel
If the issue is that the Google Play Services haven't started. Could you do the piracy check on a background thread, and then if it triggers the don't allow, check again in a minute or so just to make sure that the issue was just the Google Play Services not being started?Dunnage
H
2

It seems that your Google Play Services are unavailable. Try to check it before start your PiracyActivity:

const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000

fun AppCompatActivity.checkPlayServices(): Boolean {
    val apiAvailability = GoogleApiAvailability.getInstance()
    val resultCode = apiAvailability.isGooglePlayServicesAvailable(this)
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
                .show()
        }
        return false
    }
    return true
}

And then:

public static void showPiracyActivityIfNeeded(final Activity activity) {
    if (!BuildConfig.DEBUG && activity.checkPlayServices()) { ...

Also note, there are a lot of devices that has Google Play Services turned off because of various reasons, so check availability of Services every time you need it.

Hellenism answered 28/11, 2019 at 15:54 Comment(1)
Does this also affect if trying with manual check context.packageManager.getInstallerPackageName(context.packageName) Any suggestion ?Cynthia

© 2022 - 2024 — McMap. All rights reserved.