I am new to Cordova and am busy with some courses. Please be kind.
I am trying to create an APK that is for Android version 4.3 (Yes, it is old! But this is the only version these devices runs on).
I have read that one must change the config.xml with the necessary build details to build for a specific version, but I am simply not managing. The produced APK can be installed on my phone, but I cannot even see the APK on the device. The only reason I think is because of the APK version.
I am using VS Code and Android Studio (for the emulators).
What do I need to change, install etc., to build an Android 4.3 APK?
Do I need to install a different Cordova (I have the latest)?
Do I need to install a different Android version for Cordova (cordova platform add android)?
Do I need to install a specific Android studio API, and how?
Do I need to change my config.xml?
Here is my config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test.ngcordova" version="4.3.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>ngCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
<engine name="ios" spec="~4.5.4" />
**<engine name="android" spec="~4.0.0" />**
</widget>
Note: This line changes back to <engine name="android" spec="^7.0.0" />when I run a build.
Here is a link to my Angular 4 and Cordova Boilerplate app
Have you tried to remove android platform and then adding the specific platform with the following command 'cordova platform add android#x.x.x' (replacing x.x.x with your version)? Sometimes it overwrites what you have typed in the config.xml when you run the app.
To check if you have the specific API installed you can open the SDK Manager, Android Studio -> Configure -> SDK Manager -> in SDK Platforms you can check if you have Android 4.3 installed. If not, install it. But if you don't have it, you should get an error when you are trying to run the app.
Also, do you get any errors when you are trying do a build?
Related
I have an angular app which I try to wrap in a cordova application for android. But I fail at whitelisting the requests against a server, when the cordova app on android.
When testing the cordova application as a browser application, there are no problems.
I've already read many articles and posts regarding the whitelisting behaviour on cordova, but without any results.
I'm using cordova 10. As I read, I should not use the cordova-plugin-whitelist, because in this version this plugin is already integrated in the main framework. The configuration in config.xml was already generated automatic when creating the project.
Here is my config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="de.acme.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>appname</name>
<description>description</description>
<author email="user#mail.de" href="https://mail.de">author</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<access origin="*" />
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
As you see, the tag with the access origin is available.
I have no plugins installed. But I also tried to install the cordova-plugin-whitelist. But this also makes no difference.
The requests in Angular are standard GET requests with the HTTPClient. But also other requests does not work. For example the embedding of google fonts.
The server, I want to access with my GET requests is a server in my LAN with the following address: 192.168.178.5:4003 (specific port!)
In Logcat I receive this error message:
I/chromium: [INFO:CONSOLE(1)] "request: http://192.168.178.5:4003/api/audiobooks/tags", source: file:///android_asset/www/main.a7f87f00e27ff7637d70.js (1)
W/SystemWebViewClient: URL blocked by whitelist: http://192.168.178.5:4003/api/audiobooks/tags
I think, this is just a small configuration problem. But I have no idea, where I should look for a correct solution.
Thank you
If you use HTTP, you might need to allow Android to use clear text traffic. See: https://cordova.apache.org/docs/en/dev/guide/platforms/android/index.html#android-quirks
If you are on cordova-android 10 make sure to use the latest version (10.1.0), as it contains important bug fixes.
I'm developing an app using Quasar Framework and cordova.
I'm trying to call an https API from my cordova app and it didn't work. This is a common issue and i found a lot of answers here but nothing worked for me.
Major topics says that we hava to to this in config.xml, and i did it, but didn't work:
<plugin name="cordova-plugin-whitelist" spec="1" />
<platform name="android">
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-navigation href="*" />
<allow-navigation href="about:*" />
</platform>
The funny thing is: if i try to emulate the app on android studio, or even in my android device, it works perfectly! But if i try to build and install the app on android, it doesn't work.
This is my cordova requirements:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-29,android-28,android-27,android-26,android-25,android-24,android-23,android-22,android-21
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-5.1.1\bin\gradle
Please guys could you help me? I don't know what to do anymore.
I have used Cordova to convert my web-app into an apk.
The target devices for the app are OTPC (one tablet per child) tablets in Thailand.
These tablets have Google Play disabled, so apps must be installed manually. I have followed all the usual steps such as allowing unknown sources.
After building a -debug version of the app, it installed on my Galaxy Tab 3V without issue. It also installed easily on one of the OTPC devices commonly found in schools, but on the other I get the famed parse error.
Both devices are Android 4.0.3.
So I have spent some hours trying different changes to the Cordova config.xml file with no luck so far. My problem is that I'm hunting around in the dark with no indication of what is causing the parse error on this device.
So is there a way (e.g. installing via adb) of getting more info about this specific parse error.
For what it's worth, here is my most recent config.xml file. Perhaps someone can suggest changes:
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.English_Builder" version="0.9.50" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<icon src="www/images/formatting/e_b_icon.png" />
<name>English_Builder</name>
<description>
English Builder helps Thai students of English to build vocabulary and skills, through competitive timed activities.
</description>
<author email="iansamit#gmail.com" href="https://github.com/Iansamit/English_Builder">
Ian Smith
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<platform name="android">
<allow-intent href="*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-media" spec="~2.3.0" />
</widget>
Thanks to #Gandhi for steering me to the solution. The problem turned out to be that I'd neglected to put android-minSdkVersion or android-targetSdkVersion in my config.xml. So, in the manifest, the version code had defaulted to: platformBuildVersionCode="25", which is too high for 4.0.3
For reference, here is the relevant part of my revised config.xml:
<platform name="android">
<allow-intent href="market:*" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="22" />
</platform>
Generally parse error is thrown when config.XML is not well formed or it has special characters in the XML.
In this case it seems to be an error related to android SDK version. The catch here is generally config.XML related issues will be thrown during the build time. But in this case the error is during installation which I overlooked.
So the conclusion is if you face parse error related to config.XML during build, it could be due to XML not well formed or special characters in it. If you face parse error during installation, one reason could be android SDK compatibility issue.
Update: Decompile your apk file and inspect android manifest file to check any android SDK compatibility issue
In my app i want to add google plus login. I am following this
github project. After that I add <gap:plugin> tag in config.xml but after this when i try to build app for android platform by using cordova build command it gives me an error. Error snapshot given below.
I have two questions related to this question.
Question1: When we create app using cordova by cordova create hello com.example.hello HelloWorld then many config.xml files created.
First in= Hello--> config.xml
Second in= hello-->platforms-->android-->res-->xml-->config.xml
So in which config.xml I need to add <gap:plugin> tag?
I am adding tag like this.
<gap:plugin name="cordova-plugin-googleplus" source="npm">
<param name="REVERSED_CLIENT_ID" value="myreversedclientid" />
</gap:plugin>
Question2: Why is this error occurred when i try to build app using cordova build command? (This error only occurred when i include gap:plugin tag in config.xml) (position of xml-->Hello--> config.xml) (for error look at error snapshot).
Here is my config.xml file.
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloWorld</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" version="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<gap:plugin name="cordova-plugin-googleplus" source="npm">
<param name="REVERSED_CLIENT_ID" value="myreversedclientid" />
</gap:plugin>
</widget>
You shouldn't need to add the plugin manually, you can just do
$ cordova plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myreversedclientid
This should add the plugin. To check your installed plugins, do
cordova plugin list
<gap:plugin name="nl.x-services.plugins.googleplus" version="1.0.7" />
include only this line into your config.xml for adding google+ plugin.
You will find all plugin information for Phonegap Plugins here.
google+ is third party plugin for phonegap, so I will recommend you to read API for plugin first. You will find details at given link for plugins.
And you need to add plugins into your root config.xml which you posted. No need to add it to platform config.xml
Check if you also installed the "Google Repository".sample load
I am working on Cordova Application. This loads the list of customers on Application load using https url.
While running in debug mode (using cordova run android) application works fine, but when I create release build for the same application, application is not able to connect to server. giving error "unable to connect to server. Status 0".
Here is my technology stack trace.
Cordova v4.0
Cordova Android Platform v3.6.4
Dojo Mobile 1.8.3
Update:
I found out that SSL certificate root was wrongly installed, which was treated by Andrroid browser as security issue. I found out this when I hit the certificate on android browser.
Now I have valid SSL certificate installed, verified on Android browser (after clearing cache) but still application is not able to connect to the URL.
It seems, somehow, android have cached the wrong certificate ?
I know this answer is over a year after the question was asked, but I hit the exact same issue when I published a Cordova app to the Android store for a particular client, and found this question a very helpful clue for my particular problem: Debug installed versions could connect to the client's servers, the signed release version could not.
It turns out that the issue was although we were connecting OK to servers with SSL certificates, (in this case Node.js servers,) from both web browsers, test tools like Postman, and with the debug app on devices, we needed to also provide the certificate chain with the certificate authority too on our servers before the release version would connect properly.
For anyone reaching this question having the same issue in "modern times":
Android versions 28+ need a secure connection to be setup in the manifest file, by default they are ignored in the debug build.
For a TEST release build to work you can simply set
android:usesCleartextTraffic="true"
in the application tag of you manifest or setup it correctly following the infos at
https://developer.android.com/training/articles/security-config
may answer was so late,but I think this will useful for other person.
I have the same problem and trying to fix it to different way.my problem was app build but it can not connect to the server.first I think it cause ajax have problem but it was true
and I test it to another computer and it worked,
finally I do some way like check version gradlle and config.xml,
the content of my config.xml is =>
<?xml version='1.0.0' encoding='utf-8'?>
<widget id="com.example.dr" version="1.0.0" android-versionCode="5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>myapp</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<allow-intent href="*" />
<allow-intent href="*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="SplashMaintainAspectRatio" value="true|false" />
<preference name="ShowSplashScreenSpinner" value="false"/>
<platform name="android">
<icon src="www/img/logo.png" density="ldpi" />
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
and when I check version of gradle was 2.2, I changed it to higher verison and it build and connected to server.