Error - Please have your activity extend XWalkActivity for shared mode

2.3k Views Asked by At

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.

4

There are 4 best solutions below

3
Henrik Bøgelund Lavstsen On

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.

0
HTMLlama On

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.

1
Dany Minassian On

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)
0
Mind On

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.