我在Android Studio上使用Crosswalk 13.42。通过遵循https://crosswalk-project.org/documentation/embedding_crosswalk.html的教程,我设法通过HTTP加载外部HTML。
XWalkView xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);
xWalkWebView.load("file:///android_asset/index.html", null);
我想在资源目录中加载原生index.html,但正在运行的应用不断告诉我E/AndroidProtocolHandler﹕ Unable to open asset URL: file:///android_asset/index.html
。
我的项目位于:https://github.com/Ovilia/passer-by/tree/ff4c355cf4a61ddac2ac1168a8fedde9353734fc/android。
我尝试在任何地方添加assets/index.html
,但都没有。
app/
assets/
index.html
src/
assets/
index.html
assets/
index.html
我还应该做些什么?
答案 0 :(得分:1)
事实证明,构建apk时不包含assets
。
将以下行添加到build.gradle
:
sourceSets {
main {
assets.srcDirs = ['assets']
}
}