2 Replies - 658 Views - Last Post: 09 July 2013 - 06:41 AM

#1 GaryDoo  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 131
  • Joined: 10-February 13

NullPointerException Error with v3 in app billing

Posted 09 July 2013 - 04:38 AM

Hi,

I'm hoping someone can point out where I'm going wrong. I'm not very experienced in Android and I've been asked to work on someone else's code. I've been asked to implement in app billing v3 in the application.

I have a list of buttons, so depending on which is clicked that item is purchased for this I have used a switch (below)

switch ((int) id){

                        case 2:
                            mHelper.launchPurchaseFlow(this, SKU_section2, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 3:
                            mHelper.launchPurchaseFlow(this, SKU_section3, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 4:
                            mHelper.launchPurchaseFlow(this, SKU_section4, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                        case 5:
                            mHelper.launchPurchaseFlow(this, SKU_section5, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 6:
                            mHelper.launchPurchaseFlow(this, SKU_section6, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 7:
                            mHelper.launchPurchaseFlow(this, SKU_section7, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 8:
                            mHelper.launchPurchaseFlow(this, SKU_section8, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 9:
                            mHelper.launchPurchaseFlow(this, SKU_section9, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 10:
                            mHelper.launchPurchaseFlow(this, SKU_section10, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 11:
                            mHelper.launchPurchaseFlow(this, SKU_section11, RC_REQUEST, mPurchaseFinishedListener, payload);
                            break;
                        case 12:
                            mHelper.launchPurchaseFlow(this, SKU_section12, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 13:
                            mHelper.launchPurchaseFlow(this, SKU_section13, RC_REQUEST, mPurchaseFinishedListener, payload);
                            aSync = true;
                            break;
                        case 14:
                            mHelper.launchPurchaseFlow(this, SKU_section14, RC_REQUEST, mPurchaseFinishedListener, payload);
                            break;
                        default:
                            alert("Error with Purchase");
                            break;
                    }


I have debugged the code and when it goes into the mHelper.launchPurchaseFlow that's when the error occurs, below is the verifyDeveloperPayload method
//VERIFYING THE PURCHASE PAYLOAD 
    boolean verifyDeveloperPayload(Purchase p) {
        String payload = p.getDeveloperPayload();

        return true;
    }


Here is my logcat

07-09 12:22:35.555: E/AndroidRuntime(2140): FATAL EXCEPTION: main
07-09 12:22:35.555: E/AndroidRuntime(2140): java.lang.NullPointerException
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at com.bpxpert.bloodpressure.BpListSections.verifyDeveloperPayload(BpListSections.java:241)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at com.bpxpert.bloodpressure.BpListSections$3.onIabPurchaseFinished(BpListSections.java:259)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at com.bpxpert.bloodpressure.util.IabHelper.launchPurchaseFlow(IabHelper.java:376)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at com.bpxpert.bloodpressure.util.IabHelper.launchPurchaseFlow(IabHelper.java:324)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at com.bpxpert.bloodpressure.BpListSections.onListItemClick(BpListSections.java:179)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.app.ListActivity$2.onItemClick(ListActivity.java:345)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.widget.AdapterView.performItemClick(AdapterView.java:284)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.widget.ListView.performItemClick(ListView.java:3382)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.os.Handler.handleCallback(Handler.java:587)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.os.Handler.dispatchMessage(Handler.java:92)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.os.Looper.loop(Looper.java:144)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at android.app.ActivityThread.main(ActivityThread.java:4937)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-09 12:22:35.555: E/AndroidRuntime(2140): 	at dalvik.system.NativeStart.main(Native Method)
07-09 12:22:35.565: W/ActivityManager(105):   Force finishing activity com.bpxpert.bloodpressure/.BloodPressureActivity


The strange thing is the first time i tested the apk, the sales went through, after exiting the application and reopening it these are the errors I get.

If anyone could help I'd greatly appreciate it.

Is This A Good Question/Topic? 0
  • +

Replies To: NullPointerException Error with v3 in app billing

#2 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: NullPointerException Error with v3 in app billing

Posted 09 July 2013 - 05:19 AM

My first guess would be that the Purchase argument that you pass into verifyDeveloperPayload(Purchase p) hasn't been initialized
Was This Post Helpful? 0
  • +
  • -

#3 GaryDoo  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 131
  • Joined: 10-February 13

Re: NullPointerException Error with v3 in app billing

Posted 09 July 2013 - 06:41 AM

thank you EndLessMind, upon further research it appears that in billing v3 developer payload is optional so I think I might omit it for now to prevent further errors.

However, there is also another issue with the code I'm trying to work on, the app crashes and I get the error java.land.IllegalStateException: Could not execute method of the activity when I click a button, could I post this as a different topic? Cheeky I know...but it's hard taking over someone elses code!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1