Skip to content

Android build settings

FastImage reads these from the ext block of your app’s root android/build.gradle, where React Native’s template already sets the SDK versions:

buildscript {
ext {
// React Native's settings (minSdkVersion, compileSdkVersion, …), then
// FastImage's, if you need them:
glideVersion = "<your app's Glide version>"
excludeAppGlideModule = true
}
}
Property Default Notes
compileSdkVersion 36 Set by React Native’s template, so FastImage builds with your app’s versions.
targetSdkVersion 36
minSdkVersion 24
glideVersion "5.0.7" The version of Glide (and its OkHttp integration) that FastImage uses. If your app uses Glide too, set it to your app’s version. FastImage needs 4.15 or later. Glide 5.0.9 and later need compileSdkVersion 37.
excludeAppGlideModule false Leaves out FastImage’s AppGlideModule, for an app that has its own (below). true by default when the app has expo-image.

FastImage loads its images with React Native’s OkHttp client, so your app’s interceptors and cookies apply to them. Images your app loads with Glide itself (a GlideUrl, from its own native code or another library) use the same client, with 15 s connect and read timeouts where it has none. Your own AppGlideModule (below) can register another client for them in its registerComponents: FastImage doesn’t replace it.

Android’s release builds compress PNGs, which turns a require()d APNG into a still image of its first frame. To keep it animated, turn that off in android/app/build.gradle:

android {
buildTypes {
release {
crunchPngs false
}
}
}

With Expo, set enablePngCrunchInReleaseBuilds to false under android in expo-build-properties.

APNGs loaded from a url aren’t affected.

An app has one Glide AppGlideModule. FastImage has one (FastImageGlideModule), so if your app has its own, leave FastImage’s out with excludeAppGlideModule = true (above). FastImage then adds its Glide components (for onProgress, cache: 'web', writeToCache, SVG images and cookies) to your app’s Glide setup itself, when it first loads an image.

Your module needs @GlideModule and Glide’s annotation processor in your app (annotationProcessor "com.github.bumptech.glide:compiler:<version>" in android/app/build.gradle), as Glide requires for any AppGlideModule (see Glide’s docs).

FastImage sets Glide’s disk cache size in its module, so with your own module, maxDiskSize (from the manifest, the Expo plugin or FastImage.configureCache) isn’t applied or reported. Set the disk cache size in your module’s applyOptions, as described in Glide’s configuration docs:

@GlideModule
public final class MyAppGlideModule extends AppGlideModule {
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, 200 * 1024 * 1024));
}
}

FastImage’s Expo config plugin doesn’t set excludeAppGlideModule: an Expo app with its own AppGlideModule adds it with the config plugin that adds its module.

expo-image has an AppGlideModule too, so when the app has expo-image, FastImage leaves its own out, as excludeAppGlideModule = true does. It looks for expo-image in the node_modules folders above the app’s android folder, as Node does: in a monorepo where only another app has it, set excludeAppGlideModule = false to keep FastImage’s. Images load with expo-image’s Glide setup, including its disk cache, and FastImage adds its components to it. FastImage’s network setup (its OkHttp client, with the app’s cookies, and the HTTP cache of cache: 'web' images) and its decoders (animated WebP and AVIF, APNG, SVG) only apply to FastImage’s images, so expo-image’s images and prefetches keep expo-image’s. As with an app’s own module, maxDiskSize isn’t applied or reported on Android.