24

Getting weird issue. If I run app in simulator, works fine. If I installed app by connecting android device works fine. But if I made apk by flutter build apk and installed in device.

Network image not coming? Why? any thing is going wrong? No need to provide code. For display network image, I'm using simple Image.network with url from google image.

I have tried with flutter clean and then flutter build apk --release but same issue coming

NOT WORKING BY RELEASE APK:

Uer-MacBook-Air:AppName user$ flutter build apk --release
Initializing gradle...                                              2.0s
Resolving dependencies...                                           3.1s
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                      63.4s
Built build/app/outputs/apk/release/app-release.apk (8.1MB).

WORKING BY DEBUG APK

Uer-MacBook-Air:AppName user$ flutter build apk --debug 
Initializing gradle...                                              3.5s
Resolving dependencies...                                           5.5s
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        36.2s
Built build/app/outputs/apk/debug/app-debug.apk.

Anybody has faced this type of issue? I have installed many apk by flutter build apk and that was work fine and right now not working in release mode? But when I tried with debug mode flutter build apk --debug its working fine means images are displaying?

What I have to add some permission for release mode apk?

Govaadiyo
  • 5,644
  • 9
  • 43
  • 72

6 Answers6

58

Yes, add these permissions to AndroidManifest.xml and it will work

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

Updated: only INTERNET permission is enough

<uses-permission android:name="android.permission.INTERNET" />
Long Phan
  • 857
  • 7
  • 6
14

In debug mode service extension and multiple permissions are enabled by default(in flutter)

as you are in release mode you have to add internet permission in androidmanifest.xml manually.( Just like you add it in native development)

navigate to android-> app-> src-> main-> AndroidManifest.xml and add this line outside of application scope.

 <uses-permission android:name="android.permission.INTERNET" />
Extremis II
  • 5,185
  • 2
  • 19
  • 29
9

Open your

android/app/src/main/AndroidManifest.xml

and after </application> add this android permission

<uses-permission android:name="android.permission.INTERNET" />

now, release your apk, and check.

Syed Sym
  • 164
  • 1
  • 3
6

Simply just you need to give permission of INTERNET

In Debug mode we do not face this problem because there's already permission is given.

Just go to the path

android/app/src/main/AndroidManifest.xml

Then paste this line in <manifest> tag:

<uses-permission android:name="android.permission.INTERNET"/>

enter image description here

Rohit Tagadiya
  • 3,373
  • 1
  • 25
  • 25
0

Just add this in your AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />

AndroidManifest.xml path:

android/app/src/main/AndroidManifest.xml
Yogesh Aggarwal
  • 1,071
  • 2
  • 12
  • 30
0

It might be possible that the image urls which you are using in the Image.networkImage() is blocking the app due to cors policy on that image url domain. Your app is not whitelisted to use that image url.

akash maurya
  • 607
  • 9
  • 16