I'm using CachedNetworkImage in my app and it works fine when I run it in debug or release on Android, however when I upload the aab to the Play Store and download the app from the Play Store, the image is just stuck on the placeholder.
Here's how I'm using it in the app. Note that I use a Text widget for the placeholder and the error so that I can visually debug any issues on the release version:
child: Stack(
children: <Widget>[
url != null
? CachedNetworkImage(
imageUrl: url,
errorWidget: (context, url, error) => Text("$error"),
placeholder: (context, url) => Text("Loading $url"),
imageBuilder: (context, imageProvider) => Container(
width: double.infinity,
height: 150,
decoration: BoxDecoration(
image: DecorationImage(image: imageProvider, fit: BoxFit.fitWidth),
),
),
)
: Container(),
It just stays on the placeholder and looks like this
I'm using the latest version of cached_network_image in the pubspec:
cached_network_image: ^2.4.1
Here's what I've tried so far to help narrow down the problem:
Image.network(url)
instead of CachedNetworkImage. The images load fine when I do this, so I know it's not a problem with the internet or the url.flutter run --release
. This works fine, the images load correctly.I ended up finding the solution in the github issues here github.com/Baseflow/flutter_cached_network_image/issues/497. Turns out it is a proguard issue with the sqflite library that CachedNetworkImage uses. The solution, until they fix it in the library, is to add a the default proguard file to the build.gradle file:
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true // Add these lines
shrinkResources true // Add these lines
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') // Add these lines
}
}
I'm actually really surprised no one else has posted about this on SO that I could find, seems like a major breaking change to the library.