Cordova Target Android - android

I am creating a new Cordova project. And after i have created the project, When i try to add platform using the command
cordova platform add android
i get the result
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.gofindy.android
Name: GofindyApp
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with cordova-android#4.0.0
Installing "cordova-plugin-whitelist" for android
Even though i have deleted android api22 its still creating android target:android-22
How can I change that android target to android-19 when adding android platform
i have tried this (dding two lines specifying sdk version) :
Config.xml :
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.gofindy.android" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>GofindyApp</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>
<preference name="android-minSdkVersion" value="16"/> //added by me
<preference name="android-targetSdkVersion" value="19"/> //added by me
<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:*" />
<preference name="android-targetSdkVersion" value="19 " />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
but still when i create a project and add android platform.it says
Andorid target:android-22
even though the android manifest has reflected the change.

Related

Cordova app is running smoothest when I touch screen and don't leave finger

Recently I created a Cordova app for my html5 game created in Cocos Creator engine.
After some time, I noticed the app running on android not as smooth as in browser. I googled a lot of questions but all they said problem is Cordova using some default Web View what have bad performance. I tried a lot of solutions, but no one helped me.
Today I noticed, when I run my app, touch screen and don't leave my finger, the app starts to run very smoothly (as in browser). I am wondering what is the reason of such behaviour?
Maybe there is some acceleration what start to run only when I touch the screen?
Also, any advices how I can fix lagging in Cordova android build are welcomed.
Solutions I tried:
Plugins:
ionic-webview,
crosswark-webview
setting
android:hardwareAccelerated
true/false
in the manifest
Some other small solutions from internet, I currently can't remember. No One of this helped my. Only when I touch the screen I see performance boost.
This issue occurs only on my new phone (was bought in 2020),
in the old one (2017) app runs smoothly without touch.
Thanks!
UPDATE
Cordova version is 10.0.0 (cordova-lib#10.1.0)
Platform android version is 9.1.0
config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget android-packageName="com.android.m" android-versionCode="6" id="com.android.m" version="1.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>My game</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:*" />
<preference name="AndroidXEnabled" value="true" />
<preference name="android-targetSdkVersion" value="30" />
<preference name="orientation" value="portrait" />
<preference name="Fullscreen" value="true" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>

webview - origin is not allowed by access-control-allow-origin (convert angular to mobile using cordova)

Im trying to create a angular app using Alfresco adf components (https://github.com/Alfresco/alfresco-ng2-components) and need to have a mobile app too, so i decide use cordova to generate apk.
I follow the following tutorial (https://medium.com/#nacojohn/convert-your-angular-project-to-mobile-app-using-cordova-f0384a7711a6) to generate my apk.
All seems to works fine, apk was generated and install in BlueStack, until i have to make login in my app.
Origin is not allowed by access-control-allow-origin
I know that i need to have a whitelist policy for navigating the application webview
config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="1.0.0" 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" />
<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:*" />
<allow-navigation href="*" />
<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-device" spec="^2.0.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<engine name="android" spec="^7.0.0" />
<engine name="ios" spec="^4.5.4" />
</widget>
index.html
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"
My angular web app have a dev-server proxy to fix the CORS problem
proxy.conf.json
{
"/alfresco": {
"target": "server-url",
"secure": false,
"changeOrigin": true
},
"/activiti-app": {
"target": "another-server-url",
"secure": false,
"changeOrigin": true
}
}
I dont know what i need to do more. Have i made something wrong? need to do something more?
Thanks
I think you should enable CORS in the Alfresco server, you can achieve that either by:
Including this dependency in you Alfresco extension.
Or by enabling CORS directly in the Tomcat server, full details can be found in the Tomcat documentation.
you have to enable CORS for details see Getting Started with Alfresco Application Development Framework
My problem was lack of configuration in app.config.json.
Instead of
"ecmHost": "http://{hostname}{:port}",
"bpmHost": "http://{hostname}{:port}"
I just need to set ecmHost and bpmHost to my servers and all works fine.
Thanks for helping guys

Create a specified APK version using Angular and Cordova

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?

cordova angular cannot connect to socket.io

My Ionic is working with socket.io in a webview. But when I try to compile my app to android, it seems that socket.io cannot connect to my nodejs server.
As I console everything to my node server for connection events, it doesn't trigger the connection event as seen below:
io.on('connection',function(socket){
console.log('My socket id is '+socket.id);
});
My node console works properly when I try to run the app in a browser. But using the android app extracted from cordova it seems it cannot connect.
UPDATE: this is my config.xml file in my app
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.pagemanager" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>PageManager</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" spec="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>
</widget>
i already solved my problem. what i did is to make it work in a simulator so that i can debug or see easily the errors. and i fount out the the path in mobile is always starting in file:// blah blah when i use the native script code to get current path. and thats why its not connecting to my Nodejs Server. and everything is fixed now. thank you! SO'ers.

Cordova build failed (phonegap)

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

Categories

Resources