Android4以降のBillingServiceでNullPointerException

  •  

 

Google PlayのDeveloper Consoleで「クラッシュとANR」ってのがあって、割と頻繁に上がってくるレポート。
Eclipse経由で実機にインストールしてもADB経由でapkをインストールしても出ないんだけど、Google Playで公開して実行すると必ず出るエラー。

アプリ内課金で使用しているBillingServiceが落ちてるようです。
ちなみにですが、In-app BillingはいまだにVersion 2を使用しています。

stackoverflowにも全く同じエラーの相談が上がってて早速試してみたら解決しました!
Android InApp Purchase Null pointer exception

ちなみにエラーはこんな感じ。

java.lang.RuntimeException: Unable to start service com.hoge.BillingService@415801e8 with null: java.lang.NullPointerException
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2387)
at android.app.ActivityThread.access$1900(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1221)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4511)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at jp.co.woodsmall.childcarediary.BillingService.onStart(Unknown Source)
at android.app.Service.onStartCommand(Service.java:438)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2370)
... 10 more

【修正前】

@Override
public void onStart(Intent intent, int startId) {
    handleCommand(intent, startId);
}

【修正後】

@Override
public void onStart(Intent intent, int startId) {
    if (intent != null) {
        handleCommand(intent, startId);
    }
}

stackoverflowって英語なので、とっつきにくいですが、ここを読んでて解決することが最近多い。
Google MapがAndroid4.0以降で表示されなかった時も、こちらを参考にしました。
Android4.3でGoogle Mapが表示されない

BillingServiceってGoogleから提供されているものなのでエンジニアとしては、どうしても手を入れたくない部分なんですが。
Googleの優秀なエンジニアでも未来のバグは予測できない、ってことでしょうか。

株式会社woodsmallの小林でした。
https://woodsmall.co.jp/

関連記事

コメント

この記事へのコメントはありません。

TOP