HELP: My Webviewer cannot find local HTML file

2,782 views
Skip to first unread message

RandyQ

unread,
Mar 14, 2017, 5:33:13 AM3/14/17
to MIT App Inventor Forum
Thanks in advance for helping...

I already followed this guide--
But my webviewer still shows that WEBPAGE NOT AVAILABLE screen.

When I replaced the URL to something in the internet, it shows perfectly.
But when I try a "Test.html" that I uploaded using AI2 as media file, (and I can see it stored in my phone at this path /sdcard/AppInventor/assets/test.html),
then I set the URL of my webviewer to "file:///mnt/sdcard/AppInventor/assets/test.html" , it cannot be found.
I already tried several other combinations of filepath but nothing works.

what else should I check?



Capture.PNG

RandyQ

unread,
Mar 14, 2017, 5:55:52 AM3/14/17
to MIT App Inventor Forum
I did some trial and error, and found out that the response is different when I run in Thunkable vs when I run in MIT AI2.
The local file path works fine with MIT AI2 but not in Thunkable... being not too technical, i don't really know why it behaves that way.

eero

unread,
Mar 14, 2017, 6:13:19 AM3/14/17
to MIT App Inventor Forum
Hi

Have You checked this issue of Your code:

https://puravidaapps.com/snippets1.php#htmlread
<quote>
There is one special thing to consider for HTML documents uploaded as assets into App Inventor: During development, you have to use the development path to the embedded HTML document.
file:///mnt/sdcard/AppInventor/assets/<NAME OF YOUR HTML FILE>.html


Before packaging the app, use the production path.

file:///android_asset/<NAME OF YOUR HTML FILE>.html
<quote>

--e--


Tim Carter

unread,
Mar 14, 2017, 11:01:41 AM3/14/17
to MIT App Inventor Forum
Or check out Taifun's tools extension which provides a block for the assets directory, regardless of whether you are developing or running the apk

Taifun

unread,
Mar 14, 2017, 11:29:36 AM3/14/17
to MIT App Inventor Forum
The local file path works fine with MIT AI2 but not in Thunkable.

this is a Thunkable issue, see also here, you might want to ask there
Taifun

Min Sullivan

unread,
Mar 14, 2017, 3:16:17 PM3/14/17
to MIT App Inventor Forum
I'm having the same error, too, but it's App Inventor that it's not working in...

I created the file with SaveFile in the screen's initializer, set the home URL to the correct path, and .GoHome-ed.
Screen shot 2017-03-14 at 3.14.38 PM.png
Screen shot 2017-03-14 at 3.14.49 PM.png

Taifun

unread,
Mar 14, 2017, 4:06:12 PM3/14/17
to mitappinv...@googlegroups.com
you are storing the file in the private data directory of the app. The webviewer is not able to access that directory, you will have to store it on the internal sdcard and open it from there 
EDIT: see correction below


SaveFile(text text, text fileName)
Saves text to a file. If the filename begins with a slash (/) the file is written to the sdcard (for example, writing to /myFile.txt will write the file to /sdcard/myFile.txt). If the filename does not start with a slash, it will be written in the program's private data directory where it will not be accessible to other programs on the phone. There is a special exception for the AI Companion where these files are written to /sdcard/AppInventor/data to facilitate debugging. Note that this block will overwrite a file if it already exists. If you want to add content to a file use the append block.

Taifun

Min Sullivan

unread,
Mar 14, 2017, 4:16:53 PM3/14/17
to MIT App Inventor Forum
Hmm.  I did start it with a /.
Screen shot 2017-03-14 at 3.14.38 PM.png

Taifun

unread,
Mar 14, 2017, 5:25:35 PM3/14/17
to MIT App Inventor Forum
sorry, I was confused... you store the file correctly on the internal sdcard
but later you like to read it from the assets, which does not make sense...
use the full path to the file, which is file:///mnt/sdcard/ImagesListViewVertical.html

Taifun

Min Sullivan

unread,
Mar 14, 2017, 5:42:28 PM3/14/17
to MIT App Inventor Forum
Oh my gosh! I forgot it wasn't an asset! (I've been working on asset HTML documents way too long.) Thanks!
Reply all
Reply to author
Forward
0 new messages