1
votes

I'm trying to implement a Cordova webview in a native Android application. Seems to work fine, the only problem is that the webview keeps returning this error :

File:///android_asset/www/index.html could not be loaded because ::net ERR_FILE_NOT_FOUND

I'm following this procedure : http://cordova.apache.org/docs/en/4.0.0/guide_platforms_android_webview.md.html

But where to put the assets/www folder is not clear.. I have it in app/src/ currently and it doesn't work.

I'm using Android Studio with Cordova 3.6.4 library.

Any idea ?

3

3 Answers

1
votes

Thanks for your help guys, I actually ended up finding the issue myself.

I had to add the assets folder in the build.gradle file :

sourceSets {
    main {
        assets {
            srcDir 'src/assets'
        }
    }
}

Otherwise the index.html file wouldn't be in the .apk after compiling.

0
votes

There is a typo:

android_asserts should be android_assets.

Hope that helps,

0
votes

Yeah, this kind of stuff is where the PhoneGap documentation sucks. It should be in:

/platforms/android/assets/www