Android Question [Solved] PageStarted signature error

An Schi

Well-Known Member
Licensed User
Simple App:
I have a Webview and @warwound WebViewExtras2 Library (here his documentation and here his thread).
I am adding the DefaultWebViewClient and a Sub for it with the _PageStarted event. On appstart i load a URL, this works. But when i click on a link, the app crashes in the PageStarted Sub with the error message below. Note that the error is different in release and debug mode (i have bolded it).

(Additional hints:
- some days ago my Android System WebView app recieved an update
- in the last update Erel did something with the Bitmaps, not sure if related)

Below is my project, the error, my environment and attached the zip.
I hope you can help me ;)

Project:
B4X:
#Region  Project Attributes
    #ApplicationLabel: PageStarted Sample
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #BridgeLogger: True

#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Private WebView1 As WebView
    Private WebViewExtras1 As WebViewExtras
    Private DefWVC As DefaultWebViewClient

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
   
    WebView1.Initialize("WebView")
    WebViewExtras1.Initialize(WebView1)
    DefWVC.Initialize("Def")
    WebViewExtras1.SetWebViewClient(DefWVC)
   
    Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
   
    WebView1.LoadUrl("https://www.b4x.com/android/forum/")
'    WebView1.LoadUrl("https://en.m.wikipedia.org/wiki/Main_Page")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Def_PageStarted(Url As String, FavIcon As Bitmap)
    Log("PageStarted URL = " & Url)
End Sub

Sub Def_PageFinished(Url As String)
    Log("PageFinished URL = " & Url)
End Sub

Error in Release mode:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
PageStarted URL = https://www.b4x.com/android/forum/
PageFinished URL = https://www.b4x.com/android/forum/
java.lang.Exception: Sub def_pagestarted signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:188)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at uk.co.martinpearman.b4a.webkit.DefaultWebViewClient$1.onPageStarted(DefaultWebViewClient.java:160)
at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:190)
at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:20)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)


Error in Debug mode:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
PageStarted URL = https://www.b4x.com/android/forum/
PageFinished URL = https://www.b4x.com/android/forum/
b4a.pagestarted.sample.main:_def_pagestarted, [https://www.b4x.com/android/forum/forums/code-snippets.59/, android.graphics.Bitmap@337d1c40]
Error occurred on line: 57 (Main)
java.lang.IllegalArgumentException: method b4a.pagestarted.sample.main._def_pagestarted argument 2 has type anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper, got android.graphics.Bitmap
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at uk.co.martinpearman.b4a.webkit.DefaultWebViewClient$1.onPageStarted(DefaultWebViewClient.java:160)
at com.android.webview.chromium.WebViewContentsClientAdapter.onPageStarted(WebViewContentsClientAdapter.java:190)
at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:20)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)


My environment:
- Win 10 64bit
- Galaxy S4 with Android 5.0.1
- B4A 7.30
- Configure Path to platforms\android-23\android.jar
- Java 8 Update 141


 

Attachments

  • PageStartedSample.zip
    7.1 KB · Views: 226

An Schi

Well-Known Member
Licensed User
With your code the app doesn't crash anymore :)
There is only the (ignoreable) warning about the unused variable 'FacIcon'. warning #9....

I will also post this to warwounds library thread.

Thanks a lot for the competent and fast help! :)
 
Upvote 0
Top