以XWalk(版本23.53.589.4)依赖性运行我的应用程序时,一旦调用XWalk API,就会遇到异常。这是日志的样子。
java.lang.RuntimeException: Crosswalk's APIs are not ready yet
at org.xwalk.core.XWalkView.load(XWalkView.java:372)
at com.ewise.android.api.MainActivity.onXWalkInitCompleted(MainActivity.java:869)
at org.xwalk.core.XWalkInitializer$XWalkLibraryListener.onActivateCompleted(XWalkInitializer.java:264)
at org.xwalk.core.XWalkLibraryLoader$ActivateTask.onPostExecute(XWalkLibraryLoader.java:349)
at org.xwalk.core.XWalkLibraryLoader$ActivateTask.onPostExecute(XWalkLibraryLoader.java:317)
at android.os.AsyncTask.finish(AsyncTask.java:695)
at android.os.AsyncTask.-wrap1(Unknown Source:0)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
这仅在Android API 26中发生。我已经在API 27上尝试过,它似乎工作正常。请注意,我已经预先通过XWalkInitializer初始化了XWalk。
编辑:经过进一步调查,似乎XWalkInitializer在此阶段失败。
XWalkLibraryLoader.startActivate(this);
答案 0 :(得分:0)
将其添加到“活动”中可能会有用。
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
try{
return super.dispatchTouchEvent(event);
} catch(java.lang.RuntimeException e) {
if ( e.getMessage().compareTo("Crosswalk's APIs are not ready yet") == 0 ) {
} else {
throw e;
}
}
return false;
}