1

I am working on cordova apps using mac machine and checking apps in iOS only, but when created application through windows system for android APK, my API call is not working and always returns error part, But its working fine in iOS as well as on browser

I found many same question on this, which are really old but not helping in my case and don't know why

Here are some same questions :

1) Ajax request failing in cordova/phonegap app on real device

2) AJAX Call not working in Phonegap but working normally

Tried many things but always getting {"readyState":0, "responseText":"", "status":0, "statusText":"error"}

Even created new fresh build and generate APK but result is same.

I am working with below version:

cordova -v : 9.0.0 (cordova-lib@9.0.1)

javac -version : javac 1.8.0_151

adb version : Android Debug Bridge version 1.0.40

Let me know if you required anything else from me, thanks.

Kirankumar Dafda
  • 2,354
  • 5
  • 29
  • 56
  • has your manifest declared internet usage? what does the native log say? – P. Stresow Oct 01 '19 at 14:42
  • @P.Stresow yes, there is `uses-permission for internet`, also default `whitelist plugin` properly installed. checked and changed `access origin` and checked in real android device, cache cleared still same response. – Kirankumar Dafda Oct 02 '19 at 05:19

2 Answers2

1

Finally I found the answer

https://forum.ionicframework.com/t/err-cleartext-not-permitted-in-debug-app-on-android/164101/2

Updated config.xml with android:usesCleartextTraffic

<access origin="*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
    <application android:usesCleartextTraffic="true" />
</edit-config>
<allow-navigation href="*" />

which reflect in androidManifest.xml and solved my error.

Thank you again.

Kirankumar Dafda
  • 2,354
  • 5
  • 29
  • 56
1

Below works for me:
Update "config.xml" with below line:

<allow-navigation href="*" />
Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90