question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android 10 Ajax https calls not working in release builds, works in debug builds

See original GitHub issue

Bug Report

Problem

Android 10 Ajax https calls not working in Release builds, works in debug builds, including on physical device. Only fails once the app is packaged as release bundle. This only affects ANDROID, there is no issue on iOS.

What does actually happen?

readyState : 0 Ajax error

Information

All calls are made in HTTPS. Everything works perfectly in DEBUG including on physical device. HTTPS calls fail (readyState : 0) in RELEASE builds (bundle) for no apparent reason. Obviously not a CORS/SSL issue since everything works perfectly in debug (.apk) Tested with a debug bundle, extracted to .apks via bundletools, works perfectly… Tested with standard debug APK, works perfectly.

Tested with

<access origin="*" />    
<allow-navigation href="*" />
<preference name="AndroidXEnabled" value="true" />
<preference name="AndroidInsecureFileModeEnabled" value="true" />
<preference name="android-minSdkVersion" value="23" />
<preference name="android-targetSdkVersion" value="30" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
<resource-file src="res/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />

this has no impact whatsoever (res/xml/network_security_config.xml)

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user" />  
        </trust-anchors>
    </base-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">api.domain.com</domain>
    </domain-config>
</network-security-config>

Environment, Platform, Device

Windows 10 x64 Tested on Android 6.0.1

Version information

Cordova Android 10.1.1 Cordova 10.0.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
globules-iocommented, Oct 3, 2021

Thanks @breautek I’m using Win-Acme here since we’re on Windows Server. I’m not sure I can do much about that… Which is fine in a way, it’s time to drop support to old phones…

1reaction
globules-iocommented, Oct 3, 2021

I will answer my own question, it might save someone A LOT of time. The issue is that I’m using let’s encrypt SSL certificates and I had been testing on Android 6.1.0. Following this post I just noticed that Let’s Encrypt SSL certificates will not work anymore on Android < 7.1.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cordova Android release builds Ajax not working
Like my post says, all calls are my via HTTPS and everything works perfectly in debug, including on physical device, there are no...
Read more >
$.ajax stopped working on Android - AppStudio
Note: it works on all the above Android versions with a debug build but not a release build. Works fine on iOS. Any...
Read more >
$.ajax Not working on android devices | Telerik Forums
I have an application, that needs to access an api. All ajax requests in android devices are not working. I have tested the...
Read more >
AJAX REQUEST Not working when I Run My App on an ...
All I need now is how to make Ajax call to a remote server and still return the response from the server side...
Read more >
Configure on-device developer options - Android Developers
The Settings app on Android includes a screen called Developer options that lets you configure system behaviors that help you profile and debug...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found