Skip to content

Commit 6223cbc

Browse files
committed
fix(android): support new arch on RN 0.81
1 parent e7fb09a commit 6223cbc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

android/app/proguard-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
}
2323
-keepclassmembers class com.facebook.react.runtime.ReactHostImpl {
2424
private final ** mReactHostDelegate;
25+
private final ** reactHostDelegate;
2526
}
2627
-keep interface com.facebook.react.runtime.ReactHostDelegate { *; }
2728
-keep class * implements com.facebook.react.runtime.ReactHostDelegate { *; }

android/app/src/main/java/com/appzung/codepush/react/CodePushNativeModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,14 @@ public void removeListeners(Integer count) {
896896
public ReactHostDelegate getReactHostDelegate(ReactHostImpl reactHostImpl) {
897897
try {
898898
Class<?> clazz = reactHostImpl.getClass();
899-
Field field = clazz.getDeclaredField("mReactHostDelegate");
899+
Field field;
900+
try {
901+
// RN < 0.81
902+
field = clazz.getDeclaredField("mReactHostDelegate");
903+
} catch (NoSuchFieldException e) {
904+
// RN >= 0.81
905+
field = clazz.getDeclaredField("reactHostDelegate");
906+
}
900907
field.setAccessible(true);
901908

902909
// Get the value of the field for the provided instance

0 commit comments

Comments
 (0)