4

I am getting the error

Exception junit.framework.AssertionFailedError: Please have your activity extend XWalkActivity for shared mode

in android crash reports. I have not been able to get this crash on testing. I have only used XWalkView in my game and not XWalkActivity. The implementation is as shown below.

XWalkView mXWalkView = new XWalkView(context);
MyJavaScriptInterface javaInterface = new MyJavaScriptInterface();
mXWalkView.addJavascriptInterface(javaInterface, "interOps");
mXWalkView.load("javascript:( function () { function createURL(event) { window.interOps.Callback(event.data); }window.addEventListener('message', createURL , false); } ) ()",null);
mXWalkView.load(URL, null);
mXWalkView.setResourceClient(new XWalkResourceClient(mXWalkView) {
                    @Override
                    public void onLoadFinished(XWalkView view, String url) 
                    {
                            super.onLoadFinished(view, url);
                    }
});

Crash log points to the line

XWalkView mXWalkView = new XWalkView(context);

And I have integrated crosswalk in embedded mode and not shared mode; which is why this crash log is confusing. Can anyone help me figure out why this error is being thrown.

glo
  • 1,408
  • 3
  • 25
  • 54

4 Answers4

0

I think the error is from load javascript, i tried to reform the javascript abit:

function messageCallback() { window.addEventListener('message', function(event){window.interOps.Callback(event.data);} , false);}messageCallback();

dunno it it helps, but couldn't hurt to try.

  • I do not think this is the issue as the crash log points to line "XWalkView mXWalkView = new XWalkView(context);" – glo Mar 10 '17 at 07:50
  • Oh ok, yeah I reread the exception, it looks like you need to extend your activity XWalkView, for shared mode. Don´t know what shared mode is though – Henrik Bøgelund Lavstsen Mar 12 '17 at 04:57
  • But I have integrated xwalk in embedded mode and not shared mode. – glo Mar 14 '17 at 06:21
0

It's possible that you're passing the wrong Context, if you're in the activity class try passing this otherwise try getBaseContext() or getApplicationContext() and see if you get the same error.

HTMLlama
  • 1,464
  • 2
  • 11
  • 16
0

Try it like this;

mXwalkView = new XWalkView(this, null);

Constructor for Crosswalk runtime.

Public Constructors

XWalkView(Context context, AttributeSet attrs)

Constructor for inflating via XML.

XWalkView(Context context, Activity activity)
Dharman
  • 30,962
  • 25
  • 85
  • 135
Dany Minassian
  • 189
  • 4
  • 13
  • 1
    Yep. I wonder how OP has succeed to compile, because there is not such a constructor mentioned in the [docs](https://crosswalk-project.org/apis/embeddingapidocs/reference/org/xwalk/core/XWalkView.html). – azizbekian Mar 20 '17 at 16:21
0

I do not know whether it is relevant or not. I had same error, i changed supported architectures to v7a and my application runs without errors.

Mind
  • 39
  • 6