Android Question java.lang.illegalStateException

hookshy

Well-Known Member
Licensed User
Longtime User
Migrated to target sdk 26 with new B4a 8.3
Does the inapp billing has to do any changes with new target sdk ?
Can you advise with the error bellow ?



Azi, 17:36 în versiunea 108 a aplicației
Samsung Galaxy S8 (dreamlte), Android 7.0
Raportul 1 din 1

java.lang.IllegalStateException:

at anywheresoftware.b4a.objects.IbHelper.flagStartAsync (IbHelper.java:814)

at anywheresoftware.b4a.objects.IbHelper.queryInventoryAsync (IbHelper.java:610)

at anywheresoftware.b4a.objects.IbHelper.queryInventoryAsync (IbHelper.java:636)

at anywheresoftware.b4a.inappbilling3.BillingManager3.GetOwnedProducts (BillingManager3.java:84)

at com.cote.montaj.main._manager_billingsupported (main.java:13930)

at java.lang.reflect.Method.invoke (Native Method)

at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:191)

at anywheresoftware.b4a.BA$1.run (BA.java:330)

at android.os.Handler.handleCallback (Handler.java:751)

at android.os.Handler.dispatchMessage (Handler.java:95)

at android.os.Looper.loop (Looper.java:154)

at android.app.ActivityThread.main (ActivityThread.java:6776)

at java.lang.reflect.Method.invoke (Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)

at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
 

hookshy

Well-Known Member
Licensed User
Longtime User
Make sure not to call GetOwnedProducts more than once. This can happen for example if you quickly change the orientation.
It might be ...because the app is in landscape mode ...the ads has some layout permition and shows sometimes ads in portrait mode
I think it is not goog that this is happening

here is code for start app (note that the app has force landscape mode)
B4X:
<activity android:name="com.startapp.android.publish.list3d.List3DActivity"
          android:theme="@android:style/Theme" />

<activity android:name="com.startapp.android.publish.OverlayActivity"
          android:theme="@android:style/Theme.Translucent"
          android:configChanges="orientation|keyboardHidden|screenSize" />

<activity android:name="com.startapp.android.publish.FullScreenActivity"
          android:theme="@android:style/Theme"
          android:configChanges="orientation|keyboardHidden|screenSize" />
)



B4X:
      If FirstTime Then
        primadata=True
   
      manager.Initialize("manager", key)
      manager.DebugLogging = True
      first1=True
     
      Else 
         
        primadata=False 
      End If
   



Sub Manager_BillingSupported (Supported As Boolean, Message As String)
 
   If Supported=True Then
 
    'ToastMessageShow("Supported",True)

        manager.GetOwnedProducts


 
   End If
  
End Sub

Sub manager_OwnedProducts (Success As Boolean, purchases As Map)



 'ToastMessageShow("ownedProducts:"&Success,True)
   If Success Then
 
    
      For Each pu As Purchase In purchases.Values
        ' Log(pu.ProductId & ", Purchased? " & (pu.PurchaseState = pu.STATE_PURCHASED))
         'ToastMessageShow(pu.ProductId,True)
        
        
         If pu.ProductId="cote_noads" And pu.PurchaseState=pu.STATE_PURCHASED Then
            
             adon=True
            btn_noads.Left=Activity.Width
            File.WriteString(File.DirInternal,"ads.txt","ads")
            istrial=False
            btn_pub.Left=Activity.Width
         End If
    
      Next
      
        
      
   End If
  

    preview.Color=Colors.Transparent
    preview.BringToFront


polartracking=True
btn_ucr.TextColor=guidecolor

End Sub


Sub manager_PurchaseCompleted (Success As Boolean, Product As Purchase)
If Success Then 
'user payed to remove ads
adon=True
btn_noads.Left=Activity.Width
istrial=False
File.WriteString(File.DirInternal,"ads.txt","ads")
End If 
End Sub
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
manager is a process global variable?

Is there any other case where you call manager.GetOwnedProducts?
Yes manager is a Process Globals variable
manager.getownedProducts is called only once when Billing_supported is called

I restart app like this
B4X:
Activity.Finish
StartActivity(Me)

when user press change language button
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
This one is another report related to this ibhelper ....


Ieri, 23:49 în versiunea 107 a aplicației

Samsung Galaxy Note8 (greatlte), Android 8.0
Raportul 1 din 2

java.lang.NullPointerException:

at anywheresoftware.b4a.objects.IbHelper.queryPurchases (IbHelper.java:836)

at anywheresoftware.b4a.objects.IbHelper.queryInventory (IbHelper.java:544)

at anywheresoftware.b4a.objects.IbHelper.queryInventory (IbHelper.java:523)

at anywheresoftware.b4a.objects.IbHelper$3.run (IbHelper.java:616)

at java.lang.Thread.run (Thread.java:764)
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
upgrading to b4a v8.3 did solve java.illegal.state.exception so a step forward ...
will follow the errors related to inapp purchase to see if are generated each day ..
Thank you for your support , when you find out what is wrong with this ibhelper please let us know
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
upgrading to b4a v8.3 did solve java.illegal.state.exception so a step forward ...
will follow the errors related to inapp purchase to see if are generated each day ..
Thank you for your support , when you find out what is wrong with this ibhelper please let us know
If the issue posted in the first post was resolved then you should start a new thread for any different issue.
 
Upvote 0
Top