'Flutter android app doesn't have internet connection
I built an flutter app. I used url_launcher package to navigate social links and other external browser links. And it was perfectly working on android emulator. But when I build the apk and install it on my mobile phone, URLs didn't launch. Even the network images aren't showing up.
Simply I mean the flutter app did not have internet access at all. My question is why the same code working on emulator perfectly and doesn't work on a real device?
I also checked android manifest file. There were no problems also. Here is the android manifest code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sri_lanka">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
And here is the icon button that won't open on a real mobile [1]: https://i.stack.imgur.com/TYTmU.png
Solution 1:[1]
I found a solution: You need to add some extra coding in to your android manifest to launch URLs on a real device. You can also refer to the url_launcher documentation https://pub.dev/packages/url_launcher
please refer to this link to get detailed information https://developer.android.com/training/package-visibility/use-cases#kotlin
And you need to add another line of code to manifest file in order to access internet on android mobile.
this is it =>
<uses-permission android:name="android.permission.INTERNET"/>
Here is the code you need to add in to the android manifest: manifest file path => android\app\src\main\AndroidManifest.xml
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
Solution 2:[2]
This looks like AndroindManifest.xml of debug version. try adding the same line
<uses-permission android:name="android.permission.INTERNET"/>
to AndroidManifest.xml in main folder
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vihanga Randunu |
| Solution 2 | Shahzad Umar Baig |

