To increase compatibility with older Android devices (4.0+) for my Cordova App I am wanting to use the Crosswalk Webview instead of the device webview. I am using Cordova Tools (CLI 6.3.0) for Visual Studio (2015 - Update 3) and have added the Plugin "Crosswalk WebView Engine" using the plugins panel in the config.xml. However, when I start up the app, debug it and inspect the useragenet (using "navigator.userAgent" from the console) it is not reporting as running using the Crosswalk WebView Engine.
Now I have heard some people suggest that you remove the Android platform, install the plugin and then rebuild, but that isn't fixing it for me. Perhaps I am removing the Android platform incorrectly? (I am just deleting the folder from disk).
Is this a case of my build steps being incorrect? Any assistance would be appreciated.
After persisting with this problem, assuming it to be a problem with my set-up, I got it working.
The key was to update everything. I installed the latest Java JDK (v1.8) - Updated mt CLI version to 6.5.0 - Installed any updates using the Android Update Manager (I also updated some files within Android Studio itself) and then finally installed Crosswalk (2.3.0).
Works like a dream now.
Related
I build a simple ionic project from this tutorial.
It runs on Xiaomi Mix 2 phone (android version 8.0.0) and on browser without any problem.
But when I deployed to the samsung note 2 (android version 4.4.2),
it gives an application error with this message:
net::ERR_CONNECTION_REFUSED (http://localhost:8080)
Why am I getting this error?
Any advice and suggestions will be appreciated.
Kemal.
I faced the same problem in Android 4.4, Android 6.0 but not in Android 8.0. I just added this code in config.xml to allow the localhost.
<allow-navigation href="http://localhost:8080/*"/>
For more information please follow this link:
WKWebView
Your problem is caused by the cordova-plugin-ionic-webview plugin that is part of every new or updated Ionic app.
This used to apply only to iOS, where it replaced the UIWebView with WKWebView, but on July 23rd 2018 they released version 2.0 of the plugin, that also included changes to the webview used on Android.
The Android webview now uses a local webserver at localhost:8080 to show your app instead of requesting the files directly from the file system.
Unfortunately this change also included this bit in the documentation:
Requirements
- […]
- Android: Android 5.0+ and cordova-android 6.4+
So cordova-plugin-ionic-webview just doesn’t support Android earlier than 5.0 any more, which of course means your app will not work on Android 4.x.
One solution is to downgrade the plugin to the last version that supported Android 4.x:
ionic cordova plugin add cordova-plugin-ionic-webview#1.2.1
More elaborate information and alternative solutions:
https://ionic.zone/debug/ionic-and-android-4
In case anyone is still not able to resolve this error,
Find the compatible webview version which works for you and run the below commands:
cordova plugin rm cordova-plugin-ionic-webview
cordova plugin add cordova-plugin-ionic-webview#4.1.3
In case you're using ionic, install the ionic plugin wrapper. (Skip this if your project is not an ionic project)
npm install #ionic-native/ionic-webview
Finally do clean installation of the platform and plugins. Delete
the plugins folder and run the following commands:
cordova platforms remove android
ionic cordova build android
Or, if you use ionic,
ionic cordova platforms remove android
ionic cordova build android
Additional information: Plugin version cordova-plugin-ionic-webview#4.1.3 worked for me for the below cordova and android versions:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.1.0
Android target : android-28
Android SDK Tools : 26.1.1
cordova-android : 8.1.0
You are getting the error because every function and module in Android only works from a certain version on newer. It could be 4.4.3 and up, 5.0 and up, or even 8.0 and up. It just depends. This means if and when you deploy it you will be required to select a minimum version. There is nothing you can do to fix it other than trying on a newer version. You can also change the code completely to work with older modules.
I've had same error even on new devices. After that, I've reinstalled cordova-plugin-ionic-webview plugin. Reinstallation upgraded plugin from 4.0.0 to 5.0.0 and added new line to config.xml:
<allow-navigation href="http://localhost:8100" sessionid="f8f1cc34" />
I'm still waiting for review, but hope this will help.
I had this problem for days and all the solutions I found did not work.
Ionic recommends using Capacitor to build the app and not Cordova. With Cordova does not work, on the other hand with Capacitor it works fine.
In your app directory first delete the Android folder (if any) and the one in Platform / Android folder.
I used these commands in this order launched by Powershell while staying in the APP directory
ionic build
ionic capacitor add android
npx cap open android
The first command will create a www folder.
If the last command give an error and does not open Android Studio, do it manually, (I recommend using 4.0 version). Open Android Studio → open folder, navigate to the folder named Android located in the folder in your APP and then it worked for me. In Android Sudio 4 make sure you have Gradle updated and the SDK loaded.
/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java
onReceivedError(WebView view, WebResourceRequest request,
WebResourceError error) {
super.onReceivedError(view, request, error);
if (error.getErrorCode() == WebViewClient.ERROR_CONNECT) { //net::ERR_CONNECTION_REFUSED
view.goForward();
return;
} else {
errorMessage();
}
}
I have created an Ionic Angular Project and added cordova-plugin-crosswalk-webview, since I need to integrate Webrtc.
But still, when build the android app and run in android device of version 7.1, I get error, android browser 4.0 doesnt support this.
How to make my app to use crosswalk webview instead of android?
I have created a entirely new ionic project, added the cordova plugin, before adding platform to it.
Then I build the apk, it worked with crosswalk in android.
The error I get on the console; When I run the command "phonegap emulate android"
->Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK. Looked here: C:\Users\wende\AppData\Local\Android\sdk\tools\templates\gradle\wrapper
I also experienced this issue (among many others) in my attempts to get a phonegap app to work in my environment.
I found a solution in the second response (by jcesarmobile) to this question:
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK - Android
Specifically, I had to make sure my Android Studio and Android SDK Tools were updated to the latest version, and then I had to update my Cordova Android platform to version 6.2.2.
phonegap cordova platform rm android
phonegap cordova platform add android#6.2.2
I have recently upgraded Cordoova to version 6 with android platforms 5.1.0 and ios 4.0.1 in one of the projects.
After also upgrading all plugins to the latest version the app is finally working again as it should.
However, I have noticed one very annoying difference:
With the old version when I ran the command:
cordova build android
it was compiling the app and installing it on the phone. However, it kept all the "data" from the previous version. So for example localStorage or SQLite database remained available.
When I run the same command under the new version, it replaces the app, removing all of it's "data".
As the app has a "setup process" I will now need to complete this every time I deploy a new version to the phone for testing, which is quite time consuming.
Is there any settings available to change this behavior?
I already checked the change log from Cordova but could not find any evidence what they have changed...
This issue was related to a bug in cordova, which got fixed with the latest release on March 2nd.
To fix it I did:
npm install -g cordova
cordova platform update android#5.1.1
details about the issue:
https://issues.apache.org/jira/browse/CB-10157
So in case you face a similar issue try to update your project - it worked just fine for me.
I cloned an existing ionic project from git. I have ionic 1.3.2 and cordova 4.2.0. After cloning, i cded into the directory and did an ionic browser add crosswalk. It says that crosswalk was added successfully. Then when i try to do ionic run android, it says
No platforms added.
So i do a ioinic platform add android, which gives me this error:
Failed to install 'org.apache.cordova.engine.crosswalk':CordovaError: Plugin doesn't support this project's cordova-android version. cordova-android: 3.6.4, failed version requirement: >=4.0.0-dev`.
ionic platform add android#4.0.0-dev returns
Unable to fetch platform android#4.0.0-dev: Error: version not found: cordova-android#4.0.0-dev
How do I fix this?
P.S. I am using ubuntu 14.04
The problem is crosswalk browser.
If you revert back to android webview, which sucks, but works.
ionic browser revert android
ionic platform rm android
ionic platform add android
As of today, 4/9/2015. I have been able to go back to the old projects and add crosswalk after updating node runtime, ionic, cordova
Before running ionic run android have you tried adding a directory named www?
It seems that by entering ionic platform add android, it installs the platform from the npm and the latest cordova-android version, which is.... 3.7.1 (currently)
Cordova-android 4.0 is still beta, but there's good news for those who wish to install it. You can download the 4.0 version directly from the apache github repository:
ionic platform add https://github.com/apache/cordova-android.git
There are more bugs along that road, but at least it's a working solution for that bug. It seems that apache still have plenty of issues with plugins compatibility, hopefully they'll overcome them in the next official release.
Update:
Download Intel XDK. This is just an unbelievable tool for developing mobile apps, Intel has really figured it out imo. Built in brackets, emulator, remote debugging, and most important: One button click to build apks with crosswalk for android. All you have to do is importing your www folder and you are good to go!
My app went from sluggish 5fps while scrolling to fully native feel in a click. I'm still in awe. :)