microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
8.99k stars 1.48k forks source link

java.lang.RuntimeException: An error occurred while executing doInBackground() #2760

Closed miridih-chyoon closed 2 weeks ago

miridih-chyoon commented 2 months ago

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Steps to Reproduce

Call CodePush.checkForUpdate() Call update.download()

Expected Behavior

Update downloads successfully.

Actual Behavior

image image

Environment

### Tasks
- [ ] https://github.com/microsoft/react-native-code-push/issues/1584
DordeDimitrijev commented 2 months ago

We've created a fix which will be available with next release.

Minishlink commented 1 month ago

Hello, can you please create a new v8 version with the previous changes except the ZipArchive upgrade? This ZipArchive upgrade is a bit drastic. It would be really helpful

DordeDimitrijev commented 1 month ago

Hello @Minishlink thank you for reaching out. Can you please let me know why bumping iOS version isn't suitable for you, iOS 14 is not supported for quite some time as you can see https://endoflife.date/ios ?

Minishlink commented 1 month ago

Sure, we have around ~1% of users who are on iOS < 15. This number is ~5% for the users in the StatCounter statistics. https://iosref.com/ios-usage

DordeDimitrijev commented 1 month ago

Hi @Minishlink since we won't be releasing additional fixes for v8 version i suggest you fork rncp repository and modify changes according to your needs, on the other hand you can also modify your node_modules accordingly. Here is the PR with the changes https://github.com/microsoft/react-native-code-push/pull/2709 which you can use as a reference.

Minishlink commented 1 month ago

Hello, here is the patch should somebody needs it too react-native-code-push+8.3.1.patch

diff --git a/node_modules/react-native-code-push/android/app/build.gradle b/node_modules/react-native-code-push/android/app/build.gradle
index 68ae729..43744af 100644
--- a/node_modules/react-native-code-push/android/app/build.gradle
+++ b/node_modules/react-native-code-push/android/app/build.gradle
@@ -6,6 +6,8 @@ def DEFAULT_TARGET_SDK_VERSION = 26
 def DEFAULT_MIN_SDK_VERSION = 16

 android {
+    namespace "com.microsoft.codepush.react"
+
     compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
     buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

diff --git a/node_modules/react-native-code-push/android/app/src/main/AndroidManifest.xml b/node_modules/react-native-code-push/android/app/src/main/AndroidManifest.xml
index 9b2755f..b07e428 100644
--- a/node_modules/react-native-code-push/android/app/src/main/AndroidManifest.xml
+++ b/node_modules/react-native-code-push/android/app/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.microsoft.codepush.react">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">

     <uses-permission android:name="android.permission.INTERNET" />

diff --git a/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java b/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java
index 700efac..0a6d4d8 100644
--- a/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java
+++ b/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java
@@ -9,7 +9,6 @@ import com.nimbusds.jwt.SignedJWT;

 import java.security.interfaces.*;

-
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -86,8 +85,12 @@ public class CodePushUpdateUtils {
             throw new CodePushUnknownException("Unable to compute hash of update contents.", e);
         } finally {
             try {
-                if (digestInputStream != null) digestInputStream.close();
-                if (dataStream != null) dataStream.close();
+                if (digestInputStream != null) {
+                    digestInputStream.close();
+                }
+                if (dataStream != null) {
+                    dataStream.close();
+                }
             } catch (IOException e) {
                 e.printStackTrace();
             }
@@ -98,6 +101,10 @@ public class CodePushUpdateUtils {
     }

     public static void copyNecessaryFilesFromCurrentPackage(String diffManifestFilePath, String currentPackageFolderPath, String newPackageFolderPath) throws IOException {
+        if (currentPackageFolderPath == null || !new File(currentPackageFolderPath).exists()) {
+            CodePushUtils.log("Unable to copy files from current package during diff update, because currentPackageFolderPath is invalid.");
+            return;
+        }
         FileUtils.copyDirectoryContents(currentPackageFolderPath, newPackageFolderPath);
         JSONObject diffManifest = CodePushUtils.getJsonObjectFromFile(diffManifestFilePath);
         try {
@@ -184,7 +191,7 @@ public class CodePushUpdateUtils {
     public static Map<String, Object> verifyAndDecodeJWT(String jwt, PublicKey publicKey) {
         try {
             SignedJWT signedJWT = SignedJWT.parse(jwt);
-            JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey)publicKey);
+            JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey) publicKey);
             if (signedJWT.verify(verifier)) {
                 Map<String, Object> claims = signedJWT.getJWTClaimsSet().getClaims();
                 CodePushUtils.log("JWT verification succeeded, payload content: " + claims.toString());
@@ -217,7 +224,7 @@ public class CodePushUpdateUtils {
         }
     }

-    public static String getSignatureFilePath(String updateFolderPath){
+    public static String getSignatureFilePath(String updateFolderPath) {
         return CodePushUtils.appendPathComponent(
                 CodePushUtils.appendPathComponent(updateFolderPath, CodePushConstants.CODE_PUSH_FOLDER_PREFIX),
                 CodePushConstants.BUNDLE_JWT_FILE
@@ -254,7 +261,7 @@ public class CodePushUpdateUtils {
             throw new CodePushInvalidUpdateException("The update could not be verified because it was not signed by a trusted party.");
         }

-        final String contentHash = (String)claims.get("contentHash");
+        final String contentHash = (String) claims.get("contentHash");
         if (contentHash == null) {
             throw new CodePushInvalidUpdateException("The update could not be verified because the signature did not specify a content hash.");
         }
diff --git a/node_modules/react-native-code-push/android/build.gradle b/node_modules/react-native-code-push/android/build.gradle
index b1b264a..31a5248 100644
--- a/node_modules/react-native-code-push/android/build.gradle
+++ b/node_modules/react-native-code-push/android/build.gradle
@@ -14,6 +14,9 @@ buildscript {
 }

 allprojects {
+    android {
+        namespace "com.microsoft.codepush.react"
+    }
     repositories {
         mavenLocal()
         mavenCentral()
diff --git a/node_modules/react-native-code-push/ios/CodePush.xcodeproj/project.pbxproj b/node_modules/react-native-code-push/ios/CodePush.xcodeproj/project.pbxproj
index 1c2de68..9de6c7c 100644
--- a/node_modules/react-native-code-push/ios/CodePush.xcodeproj/project.pbxproj
+++ b/node_modules/react-native-code-push/ios/CodePush.xcodeproj/project.pbxproj
@@ -231,6 +231,7 @@
        F886644B1F4AD1EE0036D01B /* JWTErrorDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JWTErrorDescription.h; sourceTree = "<group>"; };
        F886644C1F4AD1EE0036D01B /* JWTErrorDescription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JWTErrorDescription.m; sourceTree = "<group>"; };
        F886647B1F4ADB500036D01B /* libCodePush.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCodePush.a; sourceTree = BUILT_PRODUCTS_DIR; };
+       FF90DEF92C5A808600CA8692 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
 /* End PBXFileReference section */

 /* Begin PBXFrameworksBuildPhase section */
@@ -319,6 +320,7 @@
        58B511D21A9E6C8500147676 = {
            isa = PBXGroup;
            children = (
+               FF90DEF92C5A808600CA8692 /* PrivacyInfo.xcprivacy */,
                5498D8F51D21F14100B5EB43 /* CodePushUtils.m */,
                13BE3DEC1AC21097009241FE /* CodePush.h */,
                13BE3DED1AC21097009241FE /* CodePush.m */,
@@ -625,6 +627,7 @@
            developmentRegion = English;
            hasScannedForEncodings = 0;
            knownRegions = (
+               English,
                en,
            );
            mainGroup = 58B511D21A9E6C8500147676;
diff --git a/node_modules/react-native-code-push/ios/PrivacyInfo.xcprivacy b/node_modules/react-native-code-push/ios/PrivacyInfo.xcprivacy
new file mode 100644
index 0000000..53db892
--- /dev/null
+++ b/node_modules/react-native-code-push/ios/PrivacyInfo.xcprivacy
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+   <dict>
+       <key>NSPrivacyTracking</key>
+       <false />
+       <key>NSPrivacyCollectedDataTypes</key>
+       <array />
+       <key>NSPrivacyTrackingDomains</key>
+       <array />
+       <key>NSPrivacyAccessedAPITypes</key>
+       <array>
+           <dict>
+               <key>NSPrivacyAccessedAPIType</key>
+               <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
+               <key>NSPrivacyAccessedAPITypeReasons</key>
+               <array>
+                   <string>0A2A.1</string>
+               </array>
+           </dict>
+           <dict>
+               <key>NSPrivacyAccessedAPIType</key>
+               <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
+               <key>NSPrivacyAccessedAPITypeReasons</key>
+               <array>
+                   <string>CA92.1</string>
+               </array>
+           </dict>
+       </array>
+   </dict>
+</plist>
DmitriyKirakosyan commented 2 weeks ago

Closing.