LoginSignup
14
16

More than 5 years have passed since last update.

Android 5.0 で LVL が正常動作しない問題の対処

Last updated at Posted at 2014-11-19

Android 5.0(Lollipop) で LVL (License Verification Library) が正常動作しない問題への対処方法についてメモ。
本不具合は compileSdkVersion を 21 以上にしている場合に出ます。それ以下の場合は出ません。

Android 5.0 からは、暗黙的 Intent を使用してサービスに bind できなくなりました。
LVL は内部で暗黙的 Intent を使っており、これが正常動作しません。
(ライセンスチェック時に IllegalArgumentException が throw されてしまいます)

具体的には LicenseChecker.java の以下の処理です。

boolean bindResult = mContext
    .bindService(
        new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
        this, // ServiceConnection.
        Context.BIND_AUTO_CREATE);

ここは以下のようにしなければなりません。

Intent intent = new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));

// 明示的にパッケージ名を指定する。
intent.setPackage("com.android.vending");

boolean bindResult = mContext
    .bindService(
        intent,
        this, // ServiceConnection.
        Context.BIND_AUTO_CREATE);
14
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
16