Ionic run android works BUT apk does not access internet


#23

It’s very simple to fix the no internet issue… run the following command in your terminal in the project folder…

cordova plugin add cordova-plugin-whitelist

Also make sure you have the following in your Android manifest…

<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" />

#24

You are right! i had same issue and it was solved using your solution.


#25

Guys Thank you very much for the help ,finally with the help of this topic my similar issue was solved.

Thanks


#27

Thank you so much for this!! :slight_smile:


#28

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…


#29

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 !


#30

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" />

#31

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.


#32

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.


#33

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


#34

Adding cordova whitelist component solved it for me.


#35

best answer here. This is what solves the issue


#36

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:


#37

You sir, are a life saver.


#38

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?


#39

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


#40

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:*" />

#41

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.


#42

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


#43

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?