Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work in APK #497

Open
VincentBayliss opened this issue Nov 4, 2020 · 13 comments
Open

Does not work in APK #497

VincentBayliss opened this issue Nov 4, 2020 · 13 comments

Comments

@VincentBayliss
Copy link

🐛 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)
@renefloor
Copy link
Contributor

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?

@caobo171
Copy link

caobo171 commented Nov 4, 2020

Yeah I'm facing exactly this issue too

@VincentBayliss
Copy link
Author

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.

@Eduardocoutto
Copy link

I'm having the same problem

@VincentBayliss
Copy link
Author

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.

@caobo171
Copy link

caobo171 commented Nov 7, 2020

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
}
}

@VincentBayliss
Copy link
Author

VincentBayliss commented Nov 7, 2020

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.

@renefloor
Copy link
Contributor

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

@preetshah21699
Copy link

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.

@renefloor
Copy link
Contributor

Looks like it is indeed an issue with how minify/proguard handles the sqflite plugin: tekartik/sqflite#452 (comment)

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

@Boehrsi
Copy link

Boehrsi commented Nov 22, 2020

Just added a comment to the mentioned Sqflite issue which provides a quite simple workaround to get everything working with shrinking enabled => tekartik/sqflite#452 (comment)

@royryando
Copy link

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!

@amigax
Copy link

amigax commented Nov 9, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants