Android Question webview : android_asset --> can't load the page

freedom2000

Well-Known Member
Licensed User
Longtime User
Hi all,

I am quite new to the forum but have already read a lot and, finally decided to jump into this nice B4A adventure.

I wanted to start with something simple : a webview with an animated gif

here is the code :

B4X:
'Activity module
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.
  Dim WebView1 As WebView
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("1")
  WebView1.LoadURL("file:///android_asset/index.html")
 
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

It is very simple...
I did put the file index.html into the bottom right IDE panel under the Files folder.
I did checked that they are really into the PC Files folder.
The compilation is OK, the activity launches but the webview displays an error when executing the
WebView1.LoadURL("file:///android_asset/index.html")

I attach the full project to this post.

Any idea please ?

BTW : I have a Nexus5 kitkat4.4.2. This device is not rooted but the disk is encrypted (security policy)
 

Attachments

  • webview_test.zip
    202.2 KB · Views: 244

DonManfred

Expert
Licensed User
Longtime User
<html><body><img src="file:///android_asset/hapticraw.gif" /></body></html>

PS: Welcome in the great B4A-Community!
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
PS: Welcome in the great B4A-Community!
Thank you Manfred for this fast answer.

I tried what you said but the result is the same. The index.html file doesn't load...

Here is the corrected project
 

Attachments

  • webview_test.zip
    185.3 KB · Views: 327
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
in your first example the image wont load... i changed the html-code and run again. The image still wont load. this time due to differences in htmlcode and real name of the gif... There were two uppercasecharacters. i renamed the file to lowecase like in htmlcode and then it works.

Your updated version works on first run
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
maybe the assets are not copied correctly. try to uninstall the app B4A Example from device. Then install it again (your last edition)
Possibly you should enable USB-Debugging on device having the actual driver from google. Then you dont need the b4a bridge...
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
in your first example the image wont load... i changed the html-code and run again. The image still wont load. this time due to differences in htmlcode and real name of the gif... There were two uppercasecharacters. i renamed the file to lowecase like in htmlcode and then it works.

Your updated version works on first run

Yes I noticed that the Uppercase could do the trick, so I replaced them in my latest project... But it is not the solution for me.
I can't access to the index.html page whatever is inside :(
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
are you using the compilation in rapid debug?

Maybe you have to use one of

#DebuggerForceFullDeployment
#DebuggerForceStandardAssets

in the project attributes...

#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#DebuggerForceFullDeployment
#DebuggerForceStandardAssets
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
Manfred you are a GENIOUS

It works with the legacy debugger :)

Many thanks for your patience with me and to get the trick

and it works as well with the rapid debugger when adding

B4X:
#DebuggerForceStandardAssets : true
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This could be a bug in rapid debugger. create a thread in bug and wish-forum posting your example. Maybe erel has an solution or an idea. Maybe he find a bug and then he will fix it for next release.

Sometime the rapid debugger do not work correctly. But erel needs to know about to fix it.
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top