Skip to content

Commit ffdf3f2

Browse files
thecodrrjanicduplessis
thecodrr
authored andcommitted
Fix ClassNotFound exception in Android during Release builds (#25912)
* Add DoNotStrip annotation for Hermes This adds the @DoNotStrip annotation to disallow Proguard/R8 from stripping the AndroidUnicodeUtils class during release build and causing a `ClassNotFound` crash. * Add @DoNotStrip annotations on all methods * Update AndroidUnicodeUtils.java
1 parent eec4dc6 commit ffdf3f2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ReactAndroid/src/main/java/com/facebook/hermes/unicode/AndroidUnicodeUtils.java

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package com.facebook.hermes.unicode;
88

9+
import com.facebook.proguard.annotations.DoNotStrip;
910
import java.text.Collator;
1011
import java.text.DateFormat;
1112
import java.text.Normalizer;
@@ -14,12 +15,15 @@
1415
// TODO: use com.facebook.common.locale.Locales.getApplicationLocale() as the current locale,
1516
// rather than the device locale. This is challenging because getApplicationLocale() is only
1617
// available via DI.
18+
@DoNotStrip
1719
public class AndroidUnicodeUtils {
20+
@DoNotStrip
1821
public static int localeCompare(String left, String right) {
1922
Collator collator = Collator.getInstance();
2023
return collator.compare(left, right);
2124
}
2225

26+
@DoNotStrip
2327
public static String dateFormat(double unixtimeMs, boolean formatDate, boolean formatTime) {
2428
DateFormat format;
2529
if (formatDate && formatTime) {
@@ -34,6 +38,7 @@ public static String dateFormat(double unixtimeMs, boolean formatDate, boolean f
3438
return format.format((long) unixtimeMs).toString();
3539
}
3640

41+
@DoNotStrip
3742
public static String convertToCase(String input, int targetCase, boolean useCurrentLocale) {
3843
// These values must match CaseConversion in PlatformUnicode.h
3944
final int targetUppercase = 0;
@@ -52,6 +57,7 @@ public static String convertToCase(String input, int targetCase, boolean useCurr
5257
}
5358
}
5459

60+
@DoNotStrip
5561
public static String normalize(String input, int form) {
5662
// Values must match NormalizationForm in PlatformUnicode.h.
5763
final int formC = 0;

0 commit comments

Comments
 (0)