From c474484c507078df64bbc43893204d171274138d Mon Sep 17 00:00:00 2001 From: James Ide Date: Sat, 28 Nov 2026 02:34:09 -0800 Subject: [PATCH] Ship ExifInterface so a HEIC image does not crash Android Fresco 3.9.0 reads a HEIF image's EXIF orientation with `androidx.exifinterface.media.ExifInterface` (`HeifExifUtil.getOrientation`), but no Fresco artifact declares that dependency and neither does ReactAndroid. An app that does not depend on ExifInterface some other way throws `NoClassDefFoundError` when it decodes its first HEIC or HEIF image. Fresco catches only `IOException` there, and the error is thrown on a background thread, so it ends the process. Make `androidx.exifinterface:exifinterface` 1.4.2 a dependency of ReactAndroid so that every app that gets Fresco through React Native also gets the class. Co-Authored-By: Claude Opus 5.5 --- packages/react-native/ReactAndroid/build.gradle.kts | 3 +++ packages/react-native/gradle/libs.versions.toml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index e716449c0a1..c54d33087a4 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -769,6 +769,9 @@ dependencies { compileOnly(project(":packages:react-native:ReactAndroid:hermes-engine")) implementation(libs.androidx.collection) + // Fresco reads a HEIF's EXIF orientation through ExifInterface but doesn't + // declare it, so without it the first HEIC image throws NoClassDefFoundError + implementation(libs.androidx.exifinterface) testImplementation(libs.junit) testImplementation(libs.assertj) diff --git a/packages/react-native/gradle/libs.versions.toml b/packages/react-native/gradle/libs.versions.toml index a87f94f4e29..4bb40034c83 100644 --- a/packages/react-native/gradle/libs.versions.toml +++ b/packages/react-native/gradle/libs.versions.toml @@ -12,6 +12,7 @@ androidx-annotation = "1.6.0" androidx-appcompat = "1.7.0" androidx-autofill = "1.3.0" androidx-collection = "1.4.4" +androidx-exifinterface = "1.4.2" androidx-benchmark-macro-junit4 = "1.3.3" androidx-profileinstaller = "1.4.1" androidx-swiperefreshlayout = "1.1.0" @@ -60,6 +61,7 @@ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "a androidx-appcompat-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidx-appcompat" } androidx-autofill = { module = "androidx.autofill:autofill", version.ref = "androidx-autofill" } androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" } +androidx-exifinterface = { module = "androidx.exifinterface:exifinterface", version.ref = "androidx-exifinterface" } androidx-benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "androidx-benchmark-macro-junit4" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-junit" }