Repository navigation
Fix ProGuard/R8 crash with React Native 0.87 and AGP 9 - #976
AlexCernik wants to merge 1 commit into
Conversation
When using React Native 0.87 with AGP 9 and R8/ProGuard enabled, the app can crash on startup with the following error:
Wrong configuration of external resource loader:
java.lang.AssertionError:
Class net.time4j.android.spi.AndroidResourceLoader
has no zero argument constructor
This was not reproducible with React Native 0.86.2 and NDK 27.
This PR updates the ProGuard documentation with the rules required to prevent R8 from removing the zero-argument constructor used by Time4J:
`
-keep public class net.time4j.android.ApplicationStarter
-keep public class net.time4j.PrettyTime
-keep public class net.time4j.android.spi.AndroidResourceLoader {
public <init>();
}
`
|
|
Confirmed the same underlying crash with React Native 0.88.0 / Expo 58.0.14 and Environment: AGP 9.2.1, Gradle 9.4.1, New Architecture enabled, Android arm64, release minification and resource shrinking enabled. The library's The JS error was misleading: importing the picker reported The failure occurs during Adding just this targeted rule to the app's existing rules and rebuilding the minified release APK fixed that regression: Using the same instrumentation harness, the rebuilt APK now exposes the public zero-argument constructor and successfully constructs Besides documenting the workaround, could this constructor rule be shipped as a consumer ProGuard rule in the library? That would protect downstream apps automatically. Preserving the original exception as the cause of the JS installation error would also make this much easier to diagnose. |
When using React Native 0.87 with AGP 9 and R8/ProGuard enabled, the app can crash on startup with the following error:
Wrong configuration of external resource loader:
java.lang.AssertionError:
Class net.time4j.android.spi.AndroidResourceLoader has no zero argument constructor
This was not reproducible with React Native 0.86.2 and NDK 27.
This PR updates the ProGuard documentation with the rules required to prevent R8 from removing the zero-argument constructor used by Time4J: