什么是mac OS中android studio中正确的资产文件夹路径

时间:2016-01-28 21:40:36

标签: android android-studio android-webview

我正在尝试将html加载到webview中。

以下对我没有用处:

     webView.loadUrl("file:///assets/index.html");
     webView.loadUrl("file:///android_assets/index.html");

我的mac中的index.html实际路径是:

   app/src/main/assets/www/index.html

我甚至尝试过:

   webView.loadUrl("app/src/main/assets/www/index.html");
   webView.loadUrl("/app/src/main/assets/www/index.html");
   webView.loadUrl("~/app/src/main/assets/www/index.html");

我还试过复制原始文件路径:

webView.loadUrl("/Users/VenkataManiteja/Desktop/MaterialTabs/app/src/main/assets/www/index.html");

webView.loadUrl("file:///Users/VenkataManiteja/Desktop/MaterialTabs/app/src/main/assets/www/index.html");

但是webview无法找到我的文件。

提供文件路径的正确方法是什么?

以下内容显示在logcat中:

 01-28 16:48:34.452 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
01-28 16:48:34.452 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000bd0
01-28 16:48:34.462 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,72)
01-28 16:48:34.472 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
01-28 16:48:34.482 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000bd0
01-28 16:48:34.512 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,72)
01-28 16:48:34.522 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
01-28 16:48:34.532 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000bd0
01-28 16:48:34.542 20737-20752/info.androidhive.materialtabs E/chromium: [ERROR:buffer_manager.cc(313)] [.Parent-Compositor-0x7fd5bc907b00]GL ERROR :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
01-28 16:48:34.552 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,72)
01-28 16:48:34.562 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
01-28 16:48:34.572 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000bd0
01-28 16:48:34.582 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,72)
01-28 16:48:34.582 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
01-28 16:48:34.582 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000bd0
01-28 16:48:34.592 20737-20752/info.androidhive.materialtabs E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,72)

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

正如我在此屏幕截图中看到的 index.html在WWW文件夹中,因此您可以使用此代码。我已经在mac上测试了这些代码

    WebView myWebView = (WebView) findViewById(R.id.webview);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    myWebView.loadUrl("file:///android_asset/www/index.html");

如果您有任何疑虑,请告诉我。