Ionic run android works BUT apk does not access internet

Thank you so much for this!! :slight_smile:

My issue was due to an incorrect intermediate certificate.

Since it seems many different problems serve up similar symptoms, you can quickly rule out or diagnose the server ssl certificate issue by entering the server name at https://www.sslshopper.com. It will flag problems with your server cert. If it returns a properly set up certificate you can rule out that problem and move on to the next…

2 Likes

If it’s can help someone,

I had the same problem, I solved it by checking the javascript console of the ionic server browser page.
I read the error and understand quickly : The app try to connect to my localhost with a new and different port.

I just add a new allowing thing with the good number in my PHP webservice file :
header(‘Access-Control-Allow-Origin: http://localhost:8383’);
header(‘Access-Control-Allow-Origin: http://localhost:8100’); // NEW ASKED PORT * added *
header(“Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization”);

Good luck !

To load external images and use the Facebook API I did the following:

  1. in the project config.xml remove the line

     <preference name="android-minSdkVersion" value="16"/>
    
  2. Install the whitelist plugin

     ionic plugin add https://github.com/apache/cordova-plugin-whitelist.git
    
  3. in platforms/android/AndroidManifest.xml

     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
1 Like

Hi kkraus, I have the similar issue. Works over http but fails over https. I am new these certificates and stuff. can you please tell me how to go forward and provide me steps to solve this issue.

See my comment on how to resolve this:

You can test your certificate with online tools and then you have to resolve any found (chain) issues.

1 Like

Yes, this is the correct answer, It works for me after many hours of research, thank you very much !!

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 ?