Android Question can we trap error in Wait For (j) JobDone(j As HttpJob) ?

nickysuwandi

Member
Licensed User
Longtime User
i had sometimes error in
B4X:
Wait For (j) JobDone(j As HttpJob)

error messages

B4X:
Error occurred on line: 76 (Starter)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1041)
    at b4a.bm.mainmenu$ResumableSub_ImgSlider_GetImage.resume(mainmenu.java:812)
    at b4a.bm.mainmenu._imgslider_getimage(mainmenu.java:784)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1068)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1023)
    at b4a.bm.imageslider$ResumableSub_GetImage.resume(imageslider.java:571)
    at b4a.bm.imageslider._getimage(imageslider.java:469)
    at b4a.bm.imageslider$ResumableSub_NextImage.resume(imageslider.java:136)
    at b4a.bm.imageslider._nextimage(imageslider.java:100)
    at b4a.bm.mainmenu._updatestatepromo(mainmenu.java:482)
    at b4a.bm.mainmenu$ResumableSub_Activity_Create.resume(mainmenu.java:456)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1746)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5279)
    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:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 45 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 46 more
Caused by: java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.Common.WaitFor(Common.java:1723)
    at b4a.bm.starter$ResumableSub_DownloadImage.resume(starter.java:618)
    at b4a.bm.starter._downloadimage(starter.java:582)
    ... 49 more


I try to trap this error using try Catch Log(LastException) End Try, but diplay another error.
This my complete sub that couse error ( i put this sub in service)

B4X:
Public Sub DownloadImage (Index As Int) As ResumableSub
    Dim j As HttpJob
    j.Initialize("downloadimage", Me)
    j.Download(MainMenu.urlspromo.Get(Index))
    Wait For (j) JobDone(j As HttpJob)
    Dim x As B4XBitmap
    If j.Success Then
        x = j.GetBitmap
    Else
        x = MainMenu.ErrorImagepromo
    End If
    j.Release
    Return x
End Sub

Anyone can help find why this error, this error appeart when i upgrade using b4a ver 8.80 and never get this error in early version.

Thanks
 

nickysuwandi

Member
Licensed User
Longtime User
i had try it in release (Opfuscated) mode, my program has crash, but there no error messsage, it close my program.

this the error log when #BridgeLogger: True

B4X:
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
starter$ResumableSub_DownloadImageresume (java line: 191)
java.lang.NullPointerException
    at anywheresoftware.b4a.keywords.Common.WaitFor(Common.java:1723)
    at b4a.bm.starter$ResumableSub_DownloadImage.resume(starter.java:191)
    at b4a.bm.starter._downloadimage(starter.java:160)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1068)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1023)
    at b4a.bm.mainmenu$ResumableSub_ImgSlider_GetImage.resume(mainmenu.java:714)
    at b4a.bm.mainmenu._imgslider_getimage(mainmenu.java:688)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1068)
    at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1023)
    at b4a.bm.imageslider$ResumableSub_GetImage.resume(imageslider.java:331)
    at b4a.bm.imageslider._vvvv2(imageslider.java:239)
    at b4a.bm.imageslider$ResumableSub_NextImage.resume(imageslider.java:456)
    at b4a.bm.imageslider._vvvv4(imageslider.java:428)
    at b4a.bm.mainmenu._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5(mainmenu.java:1210)
    at b4a.bm.mainmenu$ResumableSub_Activity_Create.resume(mainmenu.java:440)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:190)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1746)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5279)
    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:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…