Ionic run android works BUT apk does not access internet

Adding cordova whitelist component solved it for me.

best answer here. This is what solves the issue

A lifesaver :slight_smile:
Did a major re-factoring to an old app and whoops no Android internet … This got it back on track just before I went for the 12 gauge :wink:

You sir, are a life saver.

Tried every possible solution provided, but still no luck. Application cannot connect to internet on release build. There is no problem on debug build, but release build cannot connect. Any other solution or fix for this issue?

We got the exact problem getting an https resource served with an autosigned certificate. Worked in standard build but not in release.
It’s probably an ERR_INSECURE_RESPONSE raised by the webview (probably because there is no mean to remotely debug release app, and weinre cannot catch that error…). Just saw @tomkuipers answer about setting ‘android:debuggable=“false”’ in the manifest to help debugging this problem with the inspector.
This is platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewClient.java:232 that does the switch.
In case of ApplicationInfo.FLAG_DEBUGGABLE , it proceeds despite the error, but in release it does not.

A workaround is to replace “super.onReceivedSslError(view, handler, error);” by “handler.proceed();”. But only for debugging purposes, because doing this will make your app automatically rejected from google play store.

Since webview does not allow to configure a certificate keychain or custom authority, the solution is to fix your certificate. See @tomkuipers answer here: From http to https -- preparing the app

I had the same problem, and I just had to add the tag from cordova-plugin-whitelist readme to my config.xml.

E.g.

<!-- Allow links to example.com -->
<allow-navigation href="http://example.com/*" />

<!-- Wildcards are allowed for the protocol, as a prefix
     to the host, or as a suffix to the path -->
<allow-navigation href="*://*.example.com/*" />

<!-- A wildcard can be used to whitelist the entire network,
     over HTTP and HTTPS.
     *NOT RECOMMENDED* -->
<allow-navigation href="*" />

<!-- The above is equivalent to these three declarations -->
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />

Hi Naveenbc, i too had the same problem… did you found any solution for that? please lemme know if you found any solution… thanks in advance.

Hi conlud, i tried your solution and added cordova-plugin-whitelist into my config.xml file. but it doesnt work for me. so can you help me out… thanks in advance

Hello. I have the same issue.

The app works fine in the browser when I use “serve” mode and works fine when I use “ionic run android -l” mode.

If I install the apk in my device, I not see any http request to my API serve. I logged the server and I can confirm that there are not receiving any request. Also I have whitelist plugin with all configuration parameters in config.xml and in AndroidManifest.xml.

I don’t know what things see. I no have idea. Any suggestion please?

@originalcode, I have the same problem. Any updates? have you solved this issue?

I still have the same problem: ionic serve work fine, even uploading the app on ionic view works fine, but when I build the app and put it on the Play Store, I get no internet… I tried all the solution above, but nothing worked so far.

Hi guys, do you have a solution about this problem ?

problem solve for me i just update everything and adjust the proxies hehe

Has anyone every seen this happen for just a subset of Android devices? I am having this problem on just these devices…

Android arrows F-05J 7.1.1
Android SO-01J 8.0.0
Android SHV37_u 6.0.1
Android SO-03J 7.1.1
Android d-01j 7

Change your code at project\resources\android\xml like above

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
     <base-config cleartextTrafficPermitted="true"/>
</network-security-config>
4 Likes

you saved mi life! after hours of struggling this solved my issue, thanks!

Thats Great… :slightly_smiling_face:

Hey guys,

I’m developing an application with Ionic/Angular as frontend and Java Spring boot as backend.

When they’re both running om my laptop the communication between them works perfectly. Currently i’m trying with the APK (both debug and signed) on my mobile phone, but it cannot make any calls to my backend. I have tried all the above suggestions but with no success.

Whitelist plugin is added, permissions are set, access-origins (*) is set and allow-navigation (set to wildcard). Am I missing something?

Thanks in advance!

Are you missing HTTPS?

I had similar symptoms, changing my API from HTTP to HTTPS solved it right away.

From Android 9 Pie and up, all requests need to have encryption. The SO answer below shows how to get around it if you need http.