Crosswalk无法找到原生html文件

时间:2015-06-17 05:20:30

标签: android android-studio crosswalk-runtime

我在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

我还应该做些什么?

1 个答案:

答案 0 :(得分:1)

事实证明,构建apk时不包含assets

将以下行添加到build.gradle

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

应该像https://github.com/Ovilia/passer-by/blob/40c9e7ac04d27783af357d41c968363f268071bf/android/app/build.gradle