flutter_cached_network_image icon indicating copy to clipboard operation
flutter_cached_network_image copied to clipboard

Does not work in APK

Open VincentBayliss opened this issue 5 years ago • 13 comments

🐛 Bug Report

Works great when running in the IDE on either an emulator or a physical device via USB but once APK has been built and distributed to any device via Firebase App Distribution, no images appear.

I have allowed INTERNET permissions in the manifest file so that is not the issue. Using a normal Network Image widget or a FadeInImage.assetNetwork widget works fine but this package does not work when deployed out via App Distribution.

Permissions added to the AndroidManifest.xml files:

Expected behavior

To see images.

Reproduction steps

Get the CachedNetworkImage widget/package working as expected (so that you see the expected images and placeholders) then build out the APK and distribute via Firebase App Distribution and any Android device.

Configuration

Version: cached_network_image: ^2.2.0+1 Android Studio 4.1 classpath 'com.android.tools.build:gradle:4.1.0'

Platform:

  • Android (on Samsung and HTC phones)

VincentBayliss avatar Nov 04 '20 11:11 VincentBayliss

That's really strange. I've never heard of that. If you just build an APK and install it directly (without the firebase app distribution), does it give the same issues?

renefloor avatar Nov 04 '20 11:11 renefloor

Yeah I'm facing exactly this issue too

caobo171 avatar Nov 04 '20 18:11 caobo171

Hi renefloor, just installed it directly and had the same issue. I have a circularAvatart with a profile picture (fed from Firestore) that works great with this package until its built into an APK and installed. I'm not saying its definitely this package thats the problem but it works fabulously in an emulator or on a hard-wired device. Its just when its bundled into an APK that the behaviour (or lack of) changes. I also suspect that there may be something a little more sinister going on here. The circularAvatar is on a card widget, along with a text-widget URL (using the url_launcher package). This does not launch either when the APK is build and installed but works great in the IDE with an emulator or hard-wired physical device. Either way, it would be nice to get to the bottom of what is going on.

Cheers, Vincent.

VincentBayliss avatar Nov 04 '20 23:11 VincentBayliss

I'm having the same problem

Eduardocoutto avatar Nov 05 '20 17:11 Eduardocoutto

I've had some luck here but I don't know why. I'll reproduce what I did last night over the weekend and see if I can figure out what steps make this work and what steps don't. I have built a "release" APK and installed it and it's working great. Just need to figure out what triggers the error and what doesn't during the build process. I will let you guys know as soon as I have figured it out.

VincentBayliss avatar Nov 05 '20 20:11 VincentBayliss

I resolved this problem by disable minify and shrink when building APK Add these lines on your app level build.gradle

buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so flutter run --release works. signingConfig signingConfigs.release shrinkResources false minifyEnabled false } }

caobo171 avatar Nov 07 '20 11:11 caobo171

Same deal, I found that if I did a "flutter run --release" and deployed the apk from that, it worked fine and the apk size was halved. The app was also optimised beyond belief and ran really fast and efficiently. Having said that though, I believe doing it that way is not advisable as it restricts compatibility. I found this was the case as I have an older test device that would not install the app when it was run this way. It would however install and run the fat version. What I did read was to do split apks to combat the compatibility problem. That is also the recommended method for distribution. I have not tested this yet but I certainly will test and report back.

VincentBayliss avatar Nov 07 '20 12:11 VincentBayliss

Are you able to get some crash logs related to this?

renefloor avatar Nov 19 '20 10:11 renefloor

The same issue is in my case. The problem is that it doesn't give any errors. It just doesn't load the image and keeps on showing the placeholder widget. I've tried to figure it out but I'm unable to.

preetshah21699 avatar Nov 20 '20 05:11 preetshah21699

Looks like it is indeed an issue with how minify/proguard handles the sqflite plugin: https://github.com/tekartik/sqflite/issues/452#issuecomment-655602329

Setting shrinkResources and minifyEnabled to false is the easiest solution for now.

renefloor avatar Nov 20 '20 08:11 renefloor

Just added a comment to the mentioned Sqflite issue which provides a quite simple workaround to get everything working with shrinking enabled => https://github.com/tekartik/sqflite/issues/452#issuecomment-731835148

Boehrsi avatar Nov 22 '20 19:11 Boehrsi

I resolved this problem by disable minify and shrink when building APK Add these lines on your app level build.gradle

buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so flutter run --release works. signingConfig signingConfigs.release shrinkResources false minifyEnabled false } }

Thanks @caobo171 it works!

royryando avatar Feb 20 '21 05:02 royryando

Problem still persists here even with that, any other ideas?

amigax avatar Nov 09 '21 14:11 amigax