Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch react-native-zip-archive@7.1.0 for the project I'm working on.
Problem
getCompressionLevel(double compressionLevel) uses a switch statement with a double selector, which is a compile error in Java. The Java language only supports switch on int, char, byte, short, String, and enums β not double.
This causes the following build failure with newer JDK/AGP versions (related to #340):
error: constant label of type int is not compatible with switch selector type double
case -1:
^
... (12 errors total)
Fix
Cast compressionLevel to int before the switch. This is safe because all valid values (-1, 0β9) are whole numbers passed from JS as number.
Here is the diff that solved my problem:
diff --git a/android/src/main/java/com/rnziparchive/RNZipArchiveModule.java b/android/src/main/java/com/rnziparchive/RNZipArchiveModule.java
index 14bd68f..cccbd99 100644
--- a/android/src/main/java/com/rnziparchive/RNZipArchiveModule.java
+++ b/android/src/main/java/com/rnziparchive/RNZipArchiveModule.java
@@ -470,7 +470,7 @@ public class RNZipArchiveModule extends ReactContextBaseJavaModule {
}
private static CompressionLevel getCompressionLevel(double compressionLevel) {
- switch (compressionLevel) {
+ switch ((int) compressionLevel) {
case -1:
return CompressionLevel.NORMAL;
case 0:
This issue body was partially generated by patch-package.
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch
react-native-zip-archive@7.1.0for the project I'm working on.Problem
getCompressionLevel(double compressionLevel)uses aswitchstatement with adoubleselector, which is a compile error in Java. The Java language only supportsswitchonint,char,byte,short,String, and enums β notdouble.This causes the following build failure with newer JDK/AGP versions (related to #340):
Fix
Cast
compressionLeveltointbefore the switch. This is safe because all valid values (-1,0β9) are whole numbers passed from JS asnumber.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.