Skip to content

Android build fails due to invalid switch on double (compressionLevel) in v7.1.0 #340

@mobilespot

Description

@mobilespot

Describe the bug
Android build fails after upgrading to react-native-zip-archive@7.1.0. The compilation crashes due to an invalid switch statement using a double type for compressionLevel.


To Reproduce
Steps to reproduce the behavior:

  1. Install react-native-zip-archive@7.1.0
  2. Run npx react-native run-android
  3. Build fails during :react-native-zip-archive:compileDebugJavaWithJavac

Error

error: patterns in switch statements are a preview feature and are disabled by default.
switch (compressionLevel)

error: constant label of type int is not compatible with switch selector type double

Expected behavior
The Android build should complete successfully without compilation errors.


Actual behavior
Build fails due to invalid Java code:

switch (compressionLevel)

where compressionLevel is a double, which is not supported in Java switch.


Env (please complete the following information):

  • Device: Android Emulator / Physical device
  • OS: Android
  • OS Version: Any
  • React Native Version: (your version here)
  • Package Version: 7.1.0
  • Java Version: (e.g. 17)

Additional context
This issue is caused by the introduction of the compressionLevel parameter in v7.1.0.
A temporary fix is to cast the value to int:

switch ((int) compressionLevel)

However, this should be fixed in the library to ensure compatibility with standard Java compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions