Android Question Problems with in app purchses

fastlingo

Member
I get this error in Crashlytics

Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{appname/com.android.billingclient.api.ProxyBillingActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.IntentSender android.app.PendingIntent.getIntentSender()' on a null object reference

Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'android.content.IntentSender android.app.PendingIntent.getIntentSender()' on a null object reference

com.android.billingclient.api.ProxyBillingActivity.onCreate (com.android.billingclient:billing@@5.0.0:11)

android.app.Activity.performCreate (Activity.java:7009)

android.app.Activity.performCreate (Activity.java:7000)

android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1214)
arrow_right
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2731)

android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2856)

android.app.ActivityThread.-wrap11



Can anyone help with this? I am not familiar with Java
 

fastlingo

Member
Post the relevant B4A code.
I don't know what the relevant code is, I guess one of these subs

B4X:
(in starter module)
Sub CheckForGooglePlayServices As Boolean   
    Try
    Dim GoogleApiAvailablity As JavaObject
    GoogleApiAvailablity = GoogleApiAvailablity.InitializeStatic("com.google.android.gms.common.GoogleApiAvailability").RunMethod("getInstance", Null)
    Dim context As JavaObject
    context.InitializeContext
    If 0<> GoogleApiAvailablity.RunMethod("isGooglePlayServicesAvailable", Array(context))  Then
        GoogleApiAvailablity.RunMethod("makeGooglePlayServicesAvailable", Array(context))
        Return False
    End If
    Return True
    
    Catch
        Return False
    End Try
End Sub

 Sub RestorePurchases
    
    If CheckForGooglePlayServices Then
    
    billing.Initialize("billing")
    Wait For (billing.ConnectIfNeeded) Billing_Connected (Result As BillingResult)
    If Result.IsSuccess Then
        Wait For (billing.QueryPurchases("inapp")) Billing_PurchasesQueryCompleted (Result As BillingResult, Purchases As List)
        'Log("Query completed: " & Result.IsSuccess)
        If Result.IsSuccess Then
            Dim found As Boolean=False
            For Each p As Purchase In Purchases
                If p.Sku = Main.productid Then
                    found=True
                    HandleAdsPurchase(p,"restorepurchases")
                End If
            Next
            
            If found=False Then
            CallSub(Main,Main.revokesub)
            End If
            
        End If
    End If
    End If
End Sub

(in main)

Sub startbilling
    
    Wait For (Starter.billing.ConnectIfNeeded) Billing_Connected (Result As BillingResult)
    If Result.IsSuccess Then
        'get the sku details
        Dim sf As Object = Starter.billing.QuerySkuDetails("inapp", Array(productid))
        Wait For (sf) Billing_SkuQueryCompleted (Result As BillingResult, SkuDetails As List)
        If Result.IsSuccess And SkuDetails.Size = 1 Then
            'start the billing process. The PurchasesUpdated event will be raised in the starter service
            Dim sku As SkuDetails=SkuDetails.Get(0)
            Result = Starter.billing.LaunchBillingFlow(sku)
            If Result.IsSuccess Then
                        
                        
                Return
            End If
        End If
    End If
    ToastMessageShow("Error starting billing process", True)
    
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…