XWalkView doesn't load downloaded files / local files and returns Assertion Error

205 views Asked by At

I am using this to implement crosswalk webview to my app

 implementation 'org.xwalk:xwalk_core_library:23.53.589.4'

And I am setting up the XWalkView like this

  private XWalkView xWalkWebView;
....
  xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);

and when I load an external HTML file like this, it loads fine

 xWalkWebView.load("website.com/htmlfile.html",(String) null);

BUT when I try loading a local file it returns an error

 xWalkWebView.load("file:///" + Environment.getExternalStorageDirectory().getAbsolutePath() + "/Download/File.html",(String) null);

The CrossWalk Activity crashes with a AssertionError warning and in some cases a NullPointerException

I have tried using XWalkView cache to store the data in its instance

 xWalkWebView.clearCache(true);
 xWalkWebView.getSettings().setCacheMode(XWalkSettings.LOAD_CACHE_ELSE_NETWORK);
 xWalkWebView.reload(2);

It didn't work, and I also tried loadUrl, loadData, and loadDataWithBaseURL all of those didn't work trying to load a local file

I have tried a bunch of stuff like separating the function creating the XWalkView to a separate class to avoid the NullPointerException and a lot of other things but nothing worked and I am wondering if there is another function to load local files using XWalkView

Any help would be appreciated, thanks!

Edit: The Warning I am getting when the activity crashes is:

W/System.err: java.lang.AssertionError
        at org.xwalk.core.internal.AndroidProtocolHandler.getAssetPath(AndroidProtocolHandler.java:82)
        at org.xwalk.core.internal.XWalkMediaPlayerResourceLoadingFilter.shouldOverrideResourceLoading(XWalkMediaPlayerResourceLoadingFilter.java:38)
        at org.chromium.media.MediaPlayerBridge.setDataSource(MediaPlayerBridge.java:205)
        at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
        at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:39)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
1

There are 1 answers

0
jhon On

I had the same problem. It was solved by modifying the Gradle version. I think the highest Gradle version (currently 4.1.2) is not compatible with XWalkView. When I changed the Gradle version to 4.0.0, it works well.