Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
[XWALK-6634] how to correctly use cordova plugin crosswalk android Created: 28/Mar/16 Updated: 21/Apr/16 Due: 29/Mar/16 Resolved: 21/Apr/16 Status: Project: Component/s: Affects Version/s: Fix Version/s: Closed Crosswalk Project WebView Plugin None Type: Reporter: Resolution: Labels: Remaining Estimate: Time Spent: Original Estimate: Environment: Bug jamie jin (Inactive) Invalid TC-NONEED Not Specified OS: Severity: Reporter Domain: Android Major oocl.com (Find related issues) None Priority: Assignee: Votes: P2 fujunwei 0 Not Specified Not Specified https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview Description Impacted Cases ============== Reproduce Test Steps ==================== as the github provided step, add the plugin to cordova android project, and in the cordovaActivity use the below code: public class MainActivity extends CordovaActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set by <content src="index.html" /> in config.xml CordovaWebViewEngine cordovawebviewEngine = super.makeWebViewEngine(); XWalkWebViewEngine xwe = (XWalkWebViewEngine) cordovawebviewEngine; XWalkCordovaView swv = (XWalkCordovaView) xwe.getView(); swv.load(launchUrl, null); } } Expected Outcome ================ should display the content of index.html Actual Outcome ============== can't run in simulator and log out the below error: The currently selected variant "armv7-debug" uses split APKs, but none of the 1 split apks are compatible with the current device with density "320" and ABIs "x86". i use the default gradle which produced by cordova Test Case Source Code ===================== Test Builds =========== Issue Analysis ============== Comments Comment by jamie jin (Inactive) [ 14/Apr/16 ] is there any update? Comment by fujunwei [ 15/Apr/16 ] Was there only variant x86 in platforms/android/build/outputs/apk directory? Comment by fujunwei [ 15/Apr/16 ] Could you please try to build without the simulator? Comment by jamie jin (Inactive) [ 15/Apr/16 ] why not use simulator? the output folder has armv7-debug apk Comment by jamie jin (Inactive) [ 17/Apr/16 ] is there any update? Comment by fujunwei [ 18/Apr/16 ] Wanming Lin Could you please help to verify it. Comment by Wanming Lin [ 18/Apr/16 ] Hao Li, please try to reproduce this issue. Comment by Hao Li [ 19/Apr/16 ] I haven't got the key point about this issue. jamie jin do you mean target devices is x86, but cordova only build a armv7-debug apk? If that, you can have a try with: cordova build android -- --gradleArg=-PcdvBuildArch=x86 Comment by jamie jin (Inactive) [ 19/Apr/16 ] yesterday i install arm-translation zip for genymotion, it will not prompt the error, but new error found as below: 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: load 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at org.xwalk.core.ReflectMethod.invoke(ReflectMethod.java:57) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at org.xwalk.core.XWalkView.load(XWalkView.java:285) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at com.cordova.xwalk.MainActivity.onCreate(MainActivity.java:37) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6237) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 04-19 21:01:07.167 1996-1996/com.cordova.xwalk E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) public class MainActivity extends CordovaActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set by <content src="index.html" /> in config.xml CordovaWebViewEngine cordovawebviewEngine = super.makeWebViewEngine(); XWalkWebViewEngine xwe = (XWalkWebViewEngine) cordovawebviewEngine; XWalkCordovaView swv = (XWalkCordovaView) xwe.getView(); swv.load(launchUrl, null); //loadUrl(launchUrl); } } seem swv.load not work, could you advice how to use xwalk in cordova project, thanks~ Comment by fujunwei [ 20/Apr/16 ] ZhuYongyong Could you please help to verify it in Genymotion , there was a similar issue you verified in https://crosswalk-project.org/jira/browse/XWALK-6141 Comment by fujunwei [ 20/Apr/16 ] Belem Zhang Does Crosswalk work finely in Genymotion with https://crosswalkproject.org/jira/browse/XWALK-6631 Comment by Belem Zhang [ 20/Apr/16 ] jamie jin 1. Are you using Crosswalk 18 on Genymotion? As you know, there crash on Genymotion issue was fixed on Crosswalk-18 (Actually fixed in upstream Chromium). 2. What's the results on real test devices? E.g. Arm device? Comment by jamie jin (Inactive) [ 20/Apr/16 ] i tried to implement XWalkInitializer.XWalkInitListener, XWalkUpdater.XWalkBackgroundUpdateListener, and @Override public void onXWalkInitCompleted() { initXwalkCordovaView(); } private void initXwalkCordovaView(){ CordovaWebViewEngine cordovawebviewEngine = super.makeWebViewEngine(); XWalkWebViewEngine xwe = (XWalkWebViewEngine) cordovawebviewEngine; XWalkCordovaView swv = (XWalkCordovaView) xwe.getView(); swv.load("file:///android_asset/www/hello.html", null); } it will not throw out java.lang.UnsupportedOperationException: load error, but the page show black, no content. below is updated code: public class MainActivity extends CordovaActivity implements XWalkInitializer.XWalkInitListener, XWalkUpdater.XWalkBackgroundUpdateListener { XWalkInitializer mXWalkInitializer; XWalkUpdater mXWalkUpdater; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set by <content src="index.html" /> in config.xml mXWalkInitializer = new XWalkInitializer(this, this); mXWalkInitializer.initAsync(); XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true); XWalkPreferences.setValue(XWalkPreferences.SUPPORT_MULTIPLE_WINDOWS, true); } private void initXwalkCordovaView(){ CordovaWebViewEngine cordovawebviewEngine = super.makeWebViewEngine(); XWalkWebViewEngine xwe = (XWalkWebViewEngine) cordovawebviewEngine; XWalkCordovaView swv = (XWalkCordovaView) xwe.getView(); swv.load("file:///android_asset/www/hello.html", null); } @Override public void onXWalkInitStarted() { } @Override public void onXWalkInitCancelled() { } @Override public void onXWalkInitFailed() { if (mXWalkUpdater == null) mXWalkUpdater = new XWalkUpdater(this, this); mXWalkUpdater.updateXWalkRuntime(); } @Override public void onXWalkInitCompleted() { initXwalkCordovaView(); } @Override public void onXWalkUpdateStarted() { } @Override public void onXWalkUpdateProgress(int i) { } @Override public void onXWalkUpdateCancelled() { } @Override public void onXWalkUpdateFailed() { } @Override public void onXWalkUpdateCompleted() { mXWalkInitializer.initAsync(); } } hello.html <!DOCTYPE html> <html> <head> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <title>Hello World</title> </head> <body> <p>Hello world!!!!</p> </body> </html> when i use index.html---- the default cordova html <!DOCTYPE html> <!-Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <html> <head> <!-Customize this policy to fit your own app's needs. For more guidance, see: https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#contentsecurity-policy Some notes: gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this: Enable inline JS: add 'unsafe-inline' to default-src --> <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> <meta name="format-detection" content="telephone=no"> <meta name="msapplication-tap-highlight" content="no"> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"> <link rel="stylesheet" type="text/css" href="css/index.css"> <title>Hello World</title> <script type="text/javascript" src="cordova.js"></script> </head> <body> <div class="app"> <h1>Apache Cordova</h1> <div id="deviceready" class="blink"> <p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p> </div> </div> <script type="text/javascript" src="js/index.js"></script> </body> </html> it will show dialog: gap_init:2 then click ok, will show another dialog.. please advice Comment by ZhuYongyong (Inactive) [ 20/Apr/16 ] I just check it using crosswalk 18.48.477.13 in x86 Genymotion , and the cordova simple app(helloworld) can launch normally. Comment by jamie jin (Inactive) [ 20/Apr/16 ] yes, just use its loadurl(launchurl); can work, but i want to use xwalkview to replace cordova view or webview to load url. if use cordovaview to loadurl, seems the crosswalk plugin has no use. Comment by jamie jin (Inactive) [ 20/Apr/16 ] how to load simple html page. Comment by fujunwei [ 21/Apr/16 ] 1, Add Cordova Crosswalk plugin cordova plugin add cordova-plugin-crosswalk-webview 2, Replace your simple html page in projectroot/www/index.html 3, Run the app cordova run android Comment by jamie jin (Inactive) [ 21/Apr/16 ] yes, this can work, but if do like this, cordova use xwalkview as its view to load html page or not? Comment by Belem Zhang [ 21/Apr/16 ] Of course, yes! Comment by jamie jin (Inactive) [ 21/Apr/16 ] so do you mean just use below code, it will use xwalkview to load html page, when activity extends CordovaActivity @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); loadUrl("file:///android_asset/www/hello.html"); } no need use xwalkcordovaview to load ? CordovaWebViewEngine cordovawebviewEngine = super.makeWebViewEngine(); XWalkWebViewEngine xwe = (XWalkWebViewEngine) cordovawebviewEngine; XWalkCordovaView swv = (XWalkCordovaView) xwe.getView(); swv.load("file:///android_asset/www/hello.html", null); Comment by fujunwei [ 21/Apr/16 ] You are right. Generated at Sun May 14 03:43:02 PDT 2017 using JIRA 7.2.7#72009sha1:68b7d86b7e8716f76c1f28a5095acccf67bb75b1.