I have a shipping Android application that displays occasional static webpages that are included in the assets folder. I have been displaying these programmatically like:
webView = new WebView(PKBDocument.KnowledgeBook.KBContext);
setContentView(webView);
webView.loadUrl("file:///android_asset/path/to the/file.html");
This works fine for API levels 3 - 9. I just recently received my shiny new Xoom and tried running the same app, and I get an error
The webpage at file:///android_asset/path/to%20the/file.html might be temporarily down or it may have moved permanently to a new web address
So, I started experimenting. The Honeycomb emulator displays these pages just fine, but my actual honeycomb device (running 3.0.1) consistently displays this error. I can read the webpage with AssetManager and then display it using loadDataWithBaseURL()
, but then the image links in the web page don't load (presumably because it can't find the path to the image file).
Any idea what changed, and how to handle this?
Try removing the space. This project and this project both work fine on my XOOM.
For me the problem was that I compiled with maven. With maven your assets should go into src/main/resources/assets
and I had them in src/main/resources
— which apparently is wrong.
It seems that Honeycomb stricter about this. If you don't use Maven then make a listing of the files in your apk file (it is just as zip file) and check that your assets correcty inside the asset directory:
7z l target/*.jar
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
p7zip Version 9.20 (locale=utf8,Utf16=on,HugeFiles=on,8 CPUs)
Listing archive: target/HP45-Droid-5.0.0.jar
--
Path = target/HP45-Droid-5.0.0.jar
Type = zip
Physical Size = 465392
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2012-01-01 19:07:10 D.... 0 0 META-INF
2012-01-01 19:07:08 ..... 125 102 META-INF/MANIFEST.MF
2012-01-01 19:07:06 D.... 0 0 assets
2012-01-01 19:07:06 ..... 93692 93629 assets/45bk.jpg
2012-01-01 19:07:06 ..... 3467 1408 assets/help.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With