Is it ok to check legality of installing paid android app by checking getInstallerPackageName?

江枫思渺然 提交于 2019-12-04 11:05:57
Jared Rummler

You should not use PackageManager#getInstallerPackageName to check if the app was installed from Google Play or for licensing purposes for the following reasons:

1) 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".

2) Checking the installer packagename for piracy reasons is equivalent to using Base64 to encrypt passwords — it's simply bad practice.

3) Users who legally purchased the app can side-load the APK or restore it from another backup application which doesn't set the correct installer packagename and get a license check error. This will most likely lead to bad reviews.

4) Like you mentioned, pirates can simply set the installer packagename when installing the APK.


You should use App Licensing or switch to In-app Billing.

While getInstallerPackage("com.example.mypackagename") does the trick and is basically a little more difficult for "hackers" to still make use of your paid app without actually paying for it, it is true it is not the best method to not let this happen.

What can you do instead?

This basically ensures that the app has been bought by the user using the phone.

  • Another thing you can do is make your app free and add in app purchases to it. In your case, just ONE in app purchase, an one time subscription. This, in my opinion, is the better solution to this problem, from two reasons:
    1. It solves your original problem, not letting the users use your premium functionalities unless they actually purchase them.
    2. It makes your app more friendly to download. Users can try it before they buy it, and this is always a plus when trying to gain more users.

Of course, there is a downside to this: you have a lot of work if your app's architecture wasn't built around this idea. However, I think it's totally worth it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!