Develop PhoneGap app for old android device - android

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.

Related

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"/>

Ionic app crashes when targeting API Level 28

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?

Debug Ionic application with android:debuggable="false"

A have installed my Ionic application on real device. The app is released, signed and has android:debuggable="false".
I faced some problems on that specific device and I need to debug it (not to create and install new --debug build).
Is there some way to debug it? To "attach" it somehow to a keystore to be authorised, or something else...? Any ideas?
I am still trying to find a better way, but so far I am able to debug my Ionic app (a signed --release build) running on a real device via the Chrome (desktop) console, by specifying:
<application android:debuggable="true">
directly in the AndroidManifest.xml file. The attribute in not overwritten when I build the project with the Ionic CLI.
What I would prefer is to set the attribute from the config.xml file, so I don't have to add it again manually in AndroidManifest.xml when I remove/add the platform.
You can add this in your config.xml to solve it.
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:debuggable="true" />
</edit-config>
Then, you can debug in Chrome.
I've just faced a similar issue (I wanted to create a debuggable Cordova app with cordova build android --release) and I've also wanted to add something to the Cordova config.xml instead of directly editing AndroidManifest.xml, which is generally a bad idea.
The following piece of code worked for me on Cordova 8.1.2, Cordova Android platform version 7.1.4. Just put this inside your config.xml file (somewhere inside the widget tag) and you should be good to go:
<config-file mode="merge" parent="/manifest" platform="android" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:debuggable="true" />
</config-file>
This will also cause the :app:lintVitalRelease linter to give you a [HardcodedDebugMode] error (and for good reason), but the APK will build fine regardless.

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