Skip to content

Commit 64e3141

Browse files
committed
fix(Native): Android assetsBundleFileName null (RN 0.74.7 Fabric Bridgeless release)
I found an issue in the Android RN 0.74.7 (New Architecture + Bridgeless) release build where the CodePush instance is newly created when reloading or updating downloads, causing the JS bundle file name to be reset to null. Since the CodePush instance is not newly created in Old Architecture and New Architecture Bridge mode, I modified it to be a singleton in Bridgeless mode as well.
1 parent 29e8e7d commit 64e3141

File tree

3 files changed

+9
-64
lines changed

3 files changed

+9
-64
lines changed

android/app/src/main/java/com/microsoft/codepush/react/CodePush.java

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@ public class CodePush implements ReactPackage {
5050
private static ReactInstanceHolder mReactInstanceHolder;
5151
private static CodePush mCurrentInstance;
5252

53-
public CodePush(Context context) {
54-
this(context, false);
55-
}
56-
5753
public static String getServiceUrl() {
5854
return mServerUrl;
5955
}
6056

61-
public CodePush(Context context, boolean isDebugMode) {
57+
public static synchronized CodePush getInstance(Context context, boolean isDebugMode) {
58+
if (mCurrentInstance == null) {
59+
mCurrentInstance = new CodePush(context, isDebugMode);
60+
}
61+
return mCurrentInstance;
62+
}
63+
64+
private CodePush(Context context, boolean isDebugMode) {
6265
mContext = context.getApplicationContext();
6366

6467
mUpdateManager = new CodePushUpdateManager(context.getFilesDir().getAbsolutePath());
@@ -88,27 +91,6 @@ public CodePush(Context context, boolean isDebugMode) {
8891
initializeUpdateAfterRestart();
8992
}
9093

91-
public CodePush(Context context, boolean isDebugMode, String serverUrl) {
92-
this(context, isDebugMode);
93-
mServerUrl = serverUrl;
94-
}
95-
96-
public CodePush(Context context, boolean isDebugMode, int publicKeyResourceDescriptor) {
97-
this(context, isDebugMode);
98-
99-
mPublicKey = getPublicKeyByResourceDescriptor(publicKeyResourceDescriptor);
100-
}
101-
102-
public CodePush(Context context, boolean isDebugMode, String serverUrl, Integer publicKeyResourceDescriptor) {
103-
this(context, isDebugMode);
104-
105-
if (publicKeyResourceDescriptor != null) {
106-
mPublicKey = getPublicKeyByResourceDescriptor(publicKeyResourceDescriptor);
107-
}
108-
109-
mServerUrl = serverUrl;
110-
}
111-
11294
private String getPublicKeyByResourceDescriptor(int publicKeyResourceDescriptor){
11395
String publicKey;
11496
try {

android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

react-native.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
android: {
55
packageImportPath: "import com.microsoft.codepush.react.CodePush;",
66
packageInstance:
7-
"new CodePush(getApplicationContext(), BuildConfig.DEBUG)",
7+
"CodePush.getInstance(getApplicationContext(), BuildConfig.DEBUG)",
88
sourceDir: './android/app'
99
}
1010
}

0 commit comments

Comments
 (0)