mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Janic Duplessis
parent
eec4dc6b72
commit
ffdf3f22c6
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
package com.facebook.hermes.unicode;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import java.text.Collator;
|
||||
import java.text.DateFormat;
|
||||
import java.text.Normalizer;
|
||||
@@ -14,12 +15,15 @@ import java.util.Locale;
|
||||
// TODO: use com.facebook.common.locale.Locales.getApplicationLocale() as the current locale,
|
||||
// rather than the device locale. This is challenging because getApplicationLocale() is only
|
||||
// available via DI.
|
||||
@DoNotStrip
|
||||
public class AndroidUnicodeUtils {
|
||||
@DoNotStrip
|
||||
public static int localeCompare(String left, String right) {
|
||||
Collator collator = Collator.getInstance();
|
||||
return collator.compare(left, right);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public static String dateFormat(double unixtimeMs, boolean formatDate, boolean formatTime) {
|
||||
DateFormat format;
|
||||
if (formatDate && formatTime) {
|
||||
@@ -34,6 +38,7 @@ public class AndroidUnicodeUtils {
|
||||
return format.format((long) unixtimeMs).toString();
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public static String convertToCase(String input, int targetCase, boolean useCurrentLocale) {
|
||||
// These values must match CaseConversion in PlatformUnicode.h
|
||||
final int targetUppercase = 0;
|
||||
@@ -52,6 +57,7 @@ public class AndroidUnicodeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public static String normalize(String input, int form) {
|
||||
// Values must match NormalizationForm in PlatformUnicode.h.
|
||||
final int formC = 0;
|
||||
|
||||
Reference in New Issue
Block a user