I have an app running successfully on Android for some time with targetSdkVersion 30 I'm compiling an update now with targetSdkVersion 31 as required by playstore. After changing targetSdkVersion INTERNET permission seems to be no longer available. Every AJAX request (new XMLHttpRequest()) is returning status 0 which means UNSENT
Any help is appreciated
Following is my config.xml
Thanks in advance
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.myapp"
version="1.8.0"
android-versionCode="10035"
xmlns="http://www.w3.org/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Verpro</name>
<description>
</description>
<author email="..." href="http://www....">
</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:*" />
<config-file after="uses-permission" parent="/manifest" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
</config-file>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
<activity android:exported="true"/>
</edit-config>
</platform>
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-geolocation" spec="~4" />
<plugin name="cordova-plugin-camera" spec="~4" />
<plugin name="cordova-plugin-barcodescanner" spec="^0.7.4" />
<preference name="android-minSdkVersion" value="30" />
<preference name="android-targetSdkVersion" value="31" />
<icon src="www/icon.png" />
<icon height="57" platform="ios" src="ios/icon-57.png" width="57" />
<icon height="72" platform="ios" src="ios/icon-72.png" width="72" />
<icon height="114" platform="ios" src="ios/icon-114.png" width="114" />
<icon height="120" platform="ios" src="ios/icon-120.png" width="120" />
<icon height="144" platform="ios" src="ios/icon-144.png" width="144" />
<icon height="152" platform="ios" src="ios/icon-152.png" width="152" />
<icon height="1024" platform="ios" src="ios/icon-1024.png" width="1024" />
</widget>
And this is the manifest:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10035" android:versionName="1.8.0" package="io.cordova.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/Theme.App.SplashScreen" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
asked Nov 11, 2022 at 14:15
fcaserio
7861 gold badge11 silver badges25 bronze badges
-
is it present in your platform/android/src/manifest.xml ?Eric– Eric2022年11月11日 14:42:55 +00:00Commented Nov 11, 2022 at 14:42
-
Yes, I added the manifest on the postfcaserio– fcaserio2022年11月11日 15:27:50 +00:00Commented Nov 11, 2022 at 15:27
-
Then it's probably not the reason why it's not working. Don't have the issue here as well. What are you using to make your calls?Eric– Eric2022年11月11日 17:55:50 +00:00Commented Nov 11, 2022 at 17:55
-
var xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.responseText == "" || xhr.responseText == null) { alert("Status: " + xhr.status); return; } } } xhr.send(params);fcaserio– fcaserio2022年11月11日 18:17:24 +00:00Commented Nov 11, 2022 at 18:17
-
It was working with API Level 30fcaserio– fcaserio2022年11月11日 18:18:01 +00:00Commented Nov 11, 2022 at 18:18
default