Http requests fails only while releasing Android build APK

I’m struggling in making my app work on Android APK release, the only scenario it fails is at generating and signing the apk. All http requests doesn’t work. (The server is running under SSL)

All Scenarios I’ve tried already:

  • ionic serve -> Works fine.
  • ionic cordova run android --device -> Works fine.
  • Works on emulators as well.

Also works fine generating the iOS build:

  • ionic cordova build ios.
  • ionic cordova run ios --device.
  • On Xcode, running build targeting a real device.
  • On Xcode, archiving and uploading it to Itunesconnect then downloading it from AppStore once it’s accepted by Apple.

So, the only case it doesn’t work is when I try to generate it’s apk through ionic cordova build android --prod --release and signing it.

Google Play also accepts the new APK, so there’s no problem with the package sign at all.

Since it works on iOS and running directly on android device, it isn’t a CORS or HTTPS certificate problem.

The code:

snippet of login.ts:

            (data) => {
                let response = data.json();
                loading.dismiss().then(loadData => {
                    if (response.access_token) {
               = response.access_token;
            }, err => {
                let error = err.json();
                loading.dismiss().then(response => {
                    if (error.message) {
                        this.showToast(error.message, 3000, 'bottom');

userService.loginUser method:

loginUser(data) {
    let headers = new Headers();
    headers.append('Access-Control-Allow-Origin', '*');
    headers.append('auth-token', '*');

            login_ds_password: data.pass
        }, headers);

Where abs is:

constructor(http) {
    this.abs = new ApiService(http);
} method:

public post(api, params, header): any {
    if (!header) {
        header = this.getHeaders();
    let options = new RequestOptions({headers: header});
    let url = + api;
    return, params, options).toPromise();

The App gets stuck when I fire “login” button and the request is made. There’s no exception thrown by the server, so the loading screen is shown forever.

I’ve running out of solutions for this and I hope you guys can help me out.

Ionic info:

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 6.4.0
Gulp CLI         : CLI version 3.9.1 Local version 3.9.1
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.0
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-gulp          : 1.0.1
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.0.0 ios 4.3.1
Ionic Framework                 : ionic-angular 3.0.1


Node       : v7.8.0
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.0
ios-sim    : 5.0.6
npm        : 5.0.3

Is it --prod or --release that breaks your app? These are two different things that can be used independently.

Try ionic cordova build android --prod and see if this still works. You can then remote debug on the device to see what is going wrong: Look at the console and network tabs for errors.

Hey @Sujan12, thank you for the reply on this.

Actually I always ran the build with only --release option, digging around for a solution I found --prod that only compress the code to run faster, no help from that tho.

I can see the requests generating the debug-mode apk through ionic cordova build android, the problem is that the app works on debug mode, it only doesn’t work if I sign the --release apk, and I can’t debug it on chrome inspect.

It’s driving me nuts, maybe it’s a issue with the requested server’s SLL certificate? If so, why it does work on iOS production app? maybe the way I’m signing the APK is preventing me from requesting SSL servers?


Don’t know if this is your issue or not (haven’t read the post in detail) but I have run into a similar issue with Android release builds, and it was indeed an issue with the SSL certificate when making https requests. Even if the https URL works in some browsers, if the intermediate certificates are not set up correctly then it would cause the request to fail on Android in release mode. Run the URL you are hitting through an SSL checker to see if there are any issues and fix those:


Yeah, Indeed a Certificate problem, deep in my mind I always knew about that, just didn’t make more tests to figure it out. thank you for the reply!

In my question at stackoverflow, someone post a workaround that makes cordova ignore failed SSL verifications works for test purpose.


Hey, I think I’m facing the same issue, click on connexion button show me an infinite loader. However the ssl analysis don’t show anything bad … Could you explain what was your mistake and what I should correct ?
Here the analysis


did you found a solution?

It solved my problem, thanks Josh.

I am having similar issue in ionic project. Found ssl certificate issue accrding to you.

Not recommended solution.
update file placed in below path according to snippet.

public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
final String packageName = this.cordova.getActivity().getPackageName();
final PackageManager pm = this.cordova.getActivity().getPackageManager();
ApplicationInfo appInfo;
try {
appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// debug = true
} else {
// debug = false
// super.onReceivedSslError(view, handler, error);
// ---->
// <----
} catch (NameNotFoundException e) {
// When it doubt, lock it out!
super.onReceivedSslError(view, handler, error);

1 Like

Hi, I have same problem. I know this cause if I change java file my app works, however I check my ssl on website you said And I see all right (or maybe I’m in a mistake).
I’d like ask for two things :slight_smile:

  • the domain where I make request is . Could you check with sslchecker if you see all right.
  • and second is… can I print someway the error that receive java function to know more about the problem?

Thanks :pray:

I also have the same issue where request does not work below Android 5. Did anyone find a solution for the issue ?? And also I did an SSL check which looks fine.

1 Like

I’ve found a solution, in my case the problem was an intermediate certificate configuration error. You can read about that on this article and this

1 Like

This solves your problem.

Before your petition.

this.http.setSSLCertMode(‘nocheck’).then((resp: any) => {
}, (error) => {

This was my issue, too. I didn’t follow the steps and just installed my cert straight away. Once I cat’d the certs and restarted NGINX no more errors.

1 Like


I have a similar issue!
In my case and don’t have any certificate SSL, I just do HTTP post to “http” URL.

In Browser and iOS device works like a charm, but on my Android Device just don’t do anything, the log console doesn’t present any error and network either.

Like @pedropapa said
“The App gets stuck when I fire “login” button and the request is made. There’s no exception thrown by the server, so the loading screen is shown forever.”

¿Someone can help me please?

My Ionic Info

   ionic (Ionic CLI)  : 4.1.0
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.2
   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 12 other plugins)


   ios-deploy : 1.9.2
   ios-sim    : 6.1.2
   NodeJS     : v10.9.0 
   npm        : 6.2.0
   OS         : macOS
   Xcode      : Xcode 10.1 Build version 10B61


   ANDROID_HOME : .../Library/Android/sdk/

Having the same issue. I’m not using https either but just http with the server ip. (no domain name too). Works perfectly fine on ionic serve, and android dev builds on the devices. But doesn’t work if I create with --prod --release flags.
This worked fine on ionic v4.0.0 but recently I’ve upgraded to v4.1.2 along with other plugins on package.json file. Now it doesn’t work any more when the apk is created with --prod --release flags

I have the same problem only using basic auth login/register to http rest and using ionic serve and emulator works fine, but when its on android device it just sits on without doing anything when i press the login or register and when i checked on the rest log nothing was coming in

I also have a problem with https and Ionic4.
The app works well with http.
If I call the https web service from a testing tool it works.
If I use the app in debug mode with https it works.

When I produce the apk it doesn’t work.
It seems that nothing arrives on the server.

If I call another https service the app works, so the problem is on the server.
Probably the certificate, but I can’t see issues using “ssllabs”.
What are the “intermediate certificates”?
I’ve produced a simple certificate with Let’s Encrypt.
It could be that the problem is due to the fact that it doesn’t run on the standard 443 port?

I don’t know how to debug the problem because in debug mode, the app works.


1 Like

I am facing similar issues on a build / release which worked fine a few months ago. Now we did some small UI modifications and trying to build it again in release and it does not work on android.

Its working fine in debug mode. using sslabs certification is also coming correctly.

My problem was on the server, after using the fullchain certificate, the app works well.
Android is more restrictive when the app runs in release mode.