• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

webview.loadUrl can't find my assets folder when using Capacitor?

I assume this has something to do with the fact that I'm using Capacitor to create an Android wrapper for a JS app but I could be wrong.

I have attached a picture of my code and the resulting "error, file not found."

I created an "assets" folder and added start-screen.html to it. I have this exact folder and file at the top of project directory for the full Capacitor project, I put it again inside the android folder, and again inside the android/app folder. It's not finding that file anywhere. Anybody have any idea what could be wrong?
 

Attachments

  • Screen Shot 2019-04-15 at 8.18.28 PM.png
    Screen Shot 2019-04-15 at 8.18.28 PM.png
    525.4 KB · Views: 126
Anybody have any idea what could be wrong?
The problem is that you're trying to load your html file before your WebView layout. You can't load your url before you have a webview to load it into. I always place setContentView() under super.onCreate(), but you have a different arrangement.

setContentView() should be loading a layout, for example:
Java:
setContentView(R.layout.activity_main);

Seeing you're code would help.

Also when you post code here use code tags as I did above so that it's easy to copy/paste and for proper code format.
 
Last edited:
Back
Top Bottom