Ionic app crashes when targeting API Level 28 - android

So, I have an Ionic app which I need to upgrade to target API Level 28 to conform to the new Playstore regulations. I'm using this in my config.xml:
<preference name="android-targetSdkVersion" value="28" />
The problem is that with this update, the app crashes everytime I use the BackgroundGeolocation plugin. I found out that I should use this code in my config.xml file, but it didn't changed anything:
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/uses-permission" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
</edit-config>
Is there any way to do this update without upgrading to Ionic 4?

Related

ERR_PROXY_CONNECTION_FAILED for ajax calls in Cordova based app - Target Android API level 30

I have a Cordova application build for Android, iOS and Windows platforms. As per latest google play store guidelines, I am generating my Cordova Android application by targeting API level 30. When I set API 30 , the rest calls(jquery Ajax calls) in my app are not working and giving ERR_PROXY_CONNECTION_FAILED in the console.
When VPN is off it is giving ERR_TIMEOUT. the same app with working fine in Android 10 and below devices without any issue. Rest Calls are accessible with https and VPN on.
To support Android 11 and Above, I have followed all the required steps to be included in Config.xml file with permissions. I have already added below changes in config file to support Android 11 and above, but facing PROXY_CONNECTION_FAILED error.
Cordova : 11.0.0
Cordova-android:9.1.0
Installed whitelist plugin
Config.xml changes
<access origin="*" subdomains="true"/>
<allow-navigation href="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<preference name="android-targetSdkVersion" value="30" />
<preference name="android-compileSdkVersion" value="30" />
<preference name="android-minSdkVersion" value="22" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge"
target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<uses-library
android:name="org.apache.http.legacy"
android:required="false"/>
</config-file>
</platform>
Also tried with network_security_config.xml file as well but that is also not working.
What else i am missing here. Does any one face same issue or any suggestions to fix this problem appreciated .
Thanks in advance

How or Where Cordova platform add android get the minSdkVersion value?

Good day,
I have a cordova mobile project, and I using "cordova platform add android" command to add my android platform.
In my config.xml, I set the minSdkVersion to 26 as follow:
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:allowBackup="false" />
<application android:networkSecurityConfig="#xml/network_security_config" />
<uses-sdk android:minSdkVersion="26" />
</edit-config>
When I run "cordova platform add android" command, the "/platforms/android" folder and its files will be removed and auto generated. after it auto generate, I check the cdv-gradle-config.json file under "platforms/android", and found the "MIN_SDK_VERSION": 22.
May I know where is this "22" come from? or any mistaken I did to cause this issue?
My cordova version is 10.0.0 (cordova-lib#10.1.0).
My gradle version is 4.7.
Set this code in config.xml
<preference name="android-minSdkVersion" value="22" />
<preference name="android-targetSdkVersion" value="31" />
This is the only tip that works.

Your application must have a valid targetSdkVersion set

I bought an app created with Cordova. I create a signed apk in Android Studio but when I try to publish the app in the Play Market I get an error:"Your application must have a valid targetSdkVersion set. To solve this problem, you need to edit your AndroidManifest.xml file and upload again the .apk file."
My config.xml:
<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="29" />
My Manifest:
<uses-sdk
android:targetSdkVersion="29"
tools:ignore="GradleOverrides" />
paste this in your manifest file
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="29"/>

Develop PhoneGap app for old android device

I have a simple, but useful app for an old android device I want to develop with Cordova PhoneGap. Going through their tutorial, by default, the current version of cordova requires android level 14 api to build apps, but I've done the following to get the app to build on my old 2.3.6 device...
In /config.xml add the following in the platform->android tag
<platform name="android">
<allow-intent href="market:*" />
<preference name="android-minSdkVersion" value="10" />
<preference name="android-targetSdkVersion" value="10" />
</platform
Edit these lines in the /platforms/android/AndroidManifest.xml file
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="fi.blogspot.codinginthecold" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" tools:overrideLibrary="org.apache.cordova" />
Like I said, the HelloWorld app compiles on the device without error, but when I actually run the app, it says the app has unfortunately stopped.
My question: As the above method failed to run the simplest app, what is best way to develop PhoneGap apps for old android devices?
Thanks.

Android - Scheduling Local Notifications on PhoneGap Build / Apache Cordova 4.1.1

I'm having issues trying to schedule local notifications on an Android app (using PhoneGap build).
I'm trying to schedule a local notification at a set date and time (e.g. September 23rd 2016 at 12:00pm).
I've tried using the following plugin:
https://build.phonegap.com/plugins/2081
My config.xml file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id = "****"
versionCode = "292000"
version = "2.9.2" >
<gap:config-file platform="android" parent="/manifest">
<application android:debuggable="true" />
</gap:config-file>
<!-- versionCode is optional and Android only -->
<name>****</name>
<description>
****
</description>
<author href="****" email="****">
****
</author>
<icon src="icon.png" />
<allow-navigation href="*" />
<access origin="*" />
<preference name="phonegap-version" value="cli-5.2.0" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="23"/>
<gap:plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />
</widget>
I then schedule the notification using the code below:
cordova.plugins.notification.local.schedule({
title: $title,
text: $message,
at: $date
});
When building for the latest PhoneGap version (cli-6.3.0), I get the following error on the build.phonegap.com site:
Error - Some official plugins have to be updated if using PhoneGap >= 4.0.0. Please upgrade the version of any plugins that may include the following file: LocalNotification.java
It seems that the plugin has not been updated for the latest version of PhoneGap causing the build to fail.
I've tried building for the latest supported version of the plugin (PhoneGap 3.7.0). The build completes successfully and when installed directly on an Android device, everything works correctly. The notifications fire as scheduled.
However, when trying to submit this build to the Google Play store, the build is rejected with the following error:
Your APK has been rejected for containing security vulnerabilities, which violates the Malicious Behavior policy. The Alerts page has more information about how to resolve the issue. If you submitted an update, the previous version of your app is still live on Google Play.
The build now needs to use v4.1.1 of Apache Cordova to be accepted by the Google Play .
I've looked around but can't find a solution anywhere. Is anyone aware of a fix, or alternatively, a different plugin that allows scheduling of local notifications on Android supporting Apache Cordova v4.1.1 or above?
Change
<gap:plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.1" source="pgb" />
to
<plugin name='cordova-plugin-whitelist' source='npm' />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="npm" />
I have fixed myself.
Changing the plugin name will work.
We need to find an appropriate plugin and replace older version in config.xml.
In my case, I have changed
<plugin name="de.appplant.cordova.plugin.local-notification" spec="0.8.4" source="pgb" />
to
<gap:plugin name="trunk.plugin.local-notification" />

Categories

Resources