Crosswalk fail to find native html file

585 views Asked by At

I'm using Crosswalk 13.42 with Android Studio. By following the tutorial at https://crosswalk-project.org/documentation/embedding_crosswalk.html , I managed to load external HTMLs through HTTP.

XWalkView xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);
xWalkWebView.load("file:///android_asset/index.html", null);

I want to load native index.html in the assets directory, but the running app keeps telling me E/AndroidProtocolHandler﹕ Unable to open asset URL: file:///android_asset/index.html.

My project is available at: https://github.com/Ovilia/passer-by/tree/ff4c355cf4a61ddac2ac1168a8fedde9353734fc/android .

I tried to add assets/index.html everywhere but none of them works.

app/
    assets/
        index.html
    src/
        assets/
            index.html
assets/
    index.html

What else should I do?

1

There are 1 answers

0
Ovilia On

It turns out that assets is not included when building apk.

Add the following lines to build.gradle:

sourceSets {
    main {
        assets.srcDirs = ['assets']
    }
}

which should be like https://github.com/Ovilia/passer-by/blob/40c9e7ac04d27783af357d41c968363f268071bf/android/app/build.gradle .