问题是:我无法使用 Chromes DevTools (chrome://inspect/#devices) 看到 CrossWalk WebView 的内容。既不是本地网站(如下图),也不是像 google.com 这样的外部网站。但它适用于独立的 chrome.apk。
配置:Chrome for Linux v. 37.0.2062.94
人行横道预构建:crosswalk-webview-9.38.199.0-arm
安卓 4.4.2/4.0.3
亚行调试工作正常。Javascript 控制台日志正在运行。我可以在手机上看到该页面。
创建网络视图
public class CrosswalkActivity extends Activity {
private final String TAG = "CrosswalkActivity";
private XWalkView xWalkView;
public static Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
context = getApplicationContext();
super.onCreate(savedInstanceState);
setContentView(R.layout.xwalkview);
xWalkView = (XWalkView) findViewById(R.id.xWalkView);
String index = FileManager.getAssetPath(context, "index.html");
Log.i(TAG, "Loading: " + index);
this.configureWebView();
xWalkView.load("file://" + index, null);
}
private Boolean configureWebView() {
try{
xWalkView.addJavascriptInterface(new JSInterface(CrosswalkActivity.context),"JSInterface");
xWalkView.setKeepScreenOn(true);
XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
return true;
}
catch(Exception e){
Log.e(TAG, e.getMessage());
return false;
}
}
}