1

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.sstatic.net/TYTmU.png

2
  • Here you will need to do some troubleshooting yourself. Open your Android phone's web browser (usually Chrome) and navigate to a random website that you know does exist. Are you able to do that? Or is the Android phone having trouble with network connections in general? Commented Feb 19, 2022 at 13:02
  • NO. My mobile phone was working correctly. To make sure the mobile is fine, I installed the apk on several devices. I had the same issue as I expected which is "URLs not working" Commented Feb 19, 2022 at 14:28

2 Answers 2

3

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

Sample image

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>
Sign up to request clarification or add additional context in comments.

1 Comment

Worked for me with just <uses-permission android:name="android.permission.INTERNET"/> added before the <application> tag.
0

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

enter image description here

3 Comments

I tried as you said. Now I can view network images. Which means now my app has internet access. But still I can not launch URLs. How ever thank you very much for your help
It might be because of the condition, you can remove the condition "canLaunch" and forcefully launch the URLs.
I had to add some extra lines of coding to solve this issue. refer to this=> stackoverflow.com/a/71186344/17377657 . Thank you very much for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.