Google In-App Billing V3 onIabPurchaseFinished 중 java.lang.NullPointerException

onActivityResult(10001,0,Intent { (has extras) }
Ending async operation: launchPurchaseFlow
Purchase canceled - Response: 1:User Canceled
Purchase finished: IabResult: User canceled. (response: -1005:User cancelled), purchase: null
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x40a3c1f8)
FATAL EXCEPTION: main
java.lang.Error: FATAL EXCEPTION [main]
Unity version     : 4.1.2f1
Device model      : Acer A500
Device fingerprint: acer/a500_ww_cus1/picasso:4.0.3/IML74K/1336617649:user/release-keys
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=10001, result=0, data=Intent { (has extras) }} to activity {com.Test.unityandroidfacebookjar/com.Test.unityandroidfacebookjar.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:2980)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3023)
at android.app.ActivityThread.access$1100(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1177)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.Test.unityandroidfacebookjar.MainActivity.verifyDeveloperPayload(MainActivity.java:451)
at com.Test.unityandroidfacebookjar.MainActivity$3.onIabPurchaseFinished(MainActivity.java:426)
at com.example.android.trivialdrivesample.util.IabHelper.handleActivityResult(IabHelper.java:491)
at com.Test.unityandroidfacebookjar.MainActivity.onActivityResult(MainActivity.java:82)
at android.app.Activity.dispatchActivityResult(Activity.java:4649)
at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
... 11 more

 구매 시도중에 유저가 캔슬하거나 구글 플레이에 인앱 관련 설정 문제로 구매 실패시에 trivialdrivesample의 샘플대로 onIabPurchaseFinished를 구현했다면 위와 같은 로그와 함께 java.lang.NullPointerException 에러가 발생합니다.

 purchase가 null이라서 발생한 문제로 purchase != null 일때 처리를 하시면 됩니다.

이 블로그의 인기 게시물

CMake Windows에 설치하기

'xxx.exe' 프로그램을 시작할 수 없습니다. 지정된 파일을 찾을 수 없습니다.

Unity3D 안드로이드 Keystore 생성하기