title: Android - Error loading local js in application
body: <p>I have an application which is basically a webview app. The website is based on angular js. Problem is the website takes a lot of time to start rendering. So I tried loading js from the asset folder. I used WebResourceResponse in my webviewclient</p>
  
  <pre><code>    @Override
      public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
  
          if(url.startsWith("https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.1/angular.min.js")){
              return loadFromAssets(url, "angular.min.js", "application/javascript", "");
                                 }
      return null;
      }
  
  private WebResourceResponse loadFromAssets( String url,
                                              String assetPath, String mimeType, String encoding){
  
      AssetManager assetManager = this.activity.getAssets();
      InputStream input = null;
      try {
          Log.d(LOG_TAG, "Loading from assets: " + assetPath);
  
          input = assetManager.open("/" + assetPath);
          WebResourceResponse response =
                  new WebResourceResponse(mimeType, encoding, input);
  
          return response;
      } catch (IOException e) {
          Log.e("WEB-APP", "Error loading " + assetPath + " from assets: " +
                  e.getMessage(), e);
      }
      return null;
  }
  </code></pre>
  
  <p>But I keep getting the filenotfound exception</p>
  
  <pre><code>    07-26 17:19:21.662  20883-21536/com.exun.brinjal D/﹕ Loading from assets: angular.min.js
  07-26 17:19:21.663  20883-21536/com.exun.brinjal E/WEB-APP﹕ Error loading angular.min.js from assets: /angular.min.js
      java.io.FileNotFoundException: /angular.min.js
              at android.content.res.AssetManager.openAsset(Native Method)
              at android.content.res.AssetManager.open(AssetManager.java:335)
              at android.content.res.AssetManager.open(AssetManager.java:309)
              at com.exun.brinjal.HelloWebViewClient.loadFromAssets(HelloWebViewClient.java:85)
              at com.exun.brinjal.HelloWebViewClient.shouldInterceptRequest(HelloWebViewClient.java:37)
              at com.android.webview.chromium.WebViewContentsClientAdapter.shouldInterceptRequest(WebViewContentsClientAdapter.java:283)
              at com.android.org.chromium.android_webview.AwContents$IoThreadClientImpl.shouldInterceptRequest(AwContents.java:244)
              at dalvik.system.NativeStart.run(Native Method)
  07-26 17:19:21.666  20883-21536/com.exun.brinjal D/﹕ Loading from assets: angular-route.min.js
  07-26 17:19:21.669  20883-21536/com.exun.brinjal E/WEB-APP﹕ Error loading angular-route.min.js from assets: /angular-route.min.js
      java.io.FileNotFoundException: /angular-route.min.js
              at android.content.res.AssetManager.openAsset(Native Method)
              at android.content.res.AssetManager.open(AssetManager.java:335)
              at android.content.res.AssetManager.open(AssetManager.java:309)
              at com.exun.brinjal.HelloWebViewClient.loadFromAssets(HelloWebViewClient.java:85)
              at com.exun.brinjal.HelloWebViewClient.shouldInterceptRequest(HelloWebViewClient.java:40)
              at com.android.webview.chromium.WebViewContentsClientAdapter.shouldInterceptRequest(WebViewContentsClientAdapter.java:283)
              at com.android.org.chromium.android_webview.AwContents$IoThreadClientImpl.shouldInterceptRequest(AwContents.java:244)
              at dalvik.system.NativeStart.run(Native Method)
  </code></pre>
  
  <p>I have tried to change <code>assetManager.open("/" + assetPath);</code> to file:/// and /assets but it doesn't help. All the js and css files I need are in the assets folder. I also want to know how will I get to load all those files also.</p>