2015/01/20

Android 5.0 で LVL を使うと IllegalArgumentException が発生する

Android Developer としては大分遅いほうだと思いますが、最近やっと手持ちの Nexus 7 を Android 5.0 にしました。
そこで、LVL を適用したアプリを立ち上げてみたところ、以下のようなエラーが。

Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.android.vending.licensing.ILicensingService }
       at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1674)
       at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1773)
       at android.app.ContextImpl.bindService(ContextImpl.java:1751)
       at android.content.ContextWrapper.bindService(ContextWrapper.java:538)
       at com.google.android.a.a.i.a(ProGuard:150)
       at com.kokufu.android.apps.sqliteviewer.MainActivity.l(ProGuard:69)
       at com.kokufu.android.apps.sqliteviewer.MainActivity.onCreate(ProGuard:65)
       at android.app.Activity.performCreate(Activity.java:5933)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
       at android.app.ActivityThread.access$800(ActivityThread.java:144)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5221)
       at java.lang.reflect.Method.invoke(Native Method)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

調べてみると、バグらしい

結構、重大なバグだと思うのですが、これまで放って置かれているのは、LVL がソース提供だからでしょうか1
リンクにもあるとおり、以下のように LVL の中身を修正することで問題は解決します。

LicenseChecker.java (修正前)
149
150
151
152
153
154
155
156
157
158
159
160
161
162
boolean bindResult = mContext
        .bindService(
                new Intent(
                        new String(
                                Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
                this, // ServiceConnection.
                Context.BIND_AUTO_CREATE);
 
if (bindResult) {
    mPendingChecks.offer(validator);
} else {
    Log.e(TAG, "Could not bind to service.");
    handleServiceConnectionError(validator);
}

LicenseChecker.java (修正後)
149
150
151
152
153
154
155
156
157
Intent serviceIntent = new Intent(
        new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));
serviceIntent.setPackage("com.android.vending");
 
boolean bindResult = mContext
        .bindService(
                serviceIntent,
                this, // ServiceConnection.
                Context.BIND_AUTO_CREATE);


  1. 少なくとも 2015/1/20 現在の Google Play Licensing Library Rev. 2 では修正されていません。 
?

0 件のコメント: