Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
miridih-chyoon opened this issue Sep 18, 2024 · 6 comments
Open
1 task done

Comments

@miridih-chyoon
Copy link

miridih-chyoon commented Sep 18, 2024

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

  • react-native-code-push version: ^8.2.1
  • react-native version: 0.72.14
  • iOS/Android/Windows version: All of Android Version
  • Does this reproduce on a debug build or release build? - Release
  • Does this reproduce on a simulator, or only on a physical device? - Physical

Tasks

  1. android bug investigating
    alexandergoncharov-zz
@DordeDimitrijev
Copy link
Contributor

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

@Minishlink
Copy link

Minishlink commented Sep 25, 2024

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
Copy link
Contributor

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
Copy link

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
Copy link
Contributor

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 #2709 which you can use as a reference.

@Minishlink
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants