Android Kotlin using WebView with android_asset

Issue

I’m using Android Studio Dolphin 2021.3.1

I have a WebView setup as follows:

val wb = WebView(this)
wb.loadUrl("file:///android_assets/html/About.html")
setContentView(wb)

I have an asset folder setup as follows:

[asset folder structure][1]

in the project disk location:

MyApp/app/src/main/assets/html

but when the WebView is displayed i get

net::ERR_FILE_NOT_FOUND

Can somebody suggest how i can access the files like this? do i have the location on disk wrong?
[1]: https://i.stack.imgur.com/c5Ury.png

Solution

Use url like this "file:///android_asset/html/About.html" with android_asset instead of android_assets

Answered By – N Droidev

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published