0

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
6
  • is it present in your platform/android/src/manifest.xml ? Commented Nov 11, 2022 at 14:42
  • Yes, I added the manifest on the post Commented 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? Commented 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); Commented Nov 11, 2022 at 18:17
  • It was working with API Level 30 Commented Nov 11, 2022 at 18:18

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.