Skip to content

java.lang.NullPointerException: Parameter specified as non-null is null: method com.facebook.react.bridge.PromiseImpl.reject, parameter code #335

@dmk3141618

Description

@dmk3141618

Root Cause Analysis

Library: react-native-zip-archive@7.0.2
Problem Code: Android native module calls promise.reject(null, "error message") when errors occur
React Native Policy Change: React Native 0.68+ no longer allows passing null as the first parameter (error code) in promise.reject()
Library Status: Latest version (7.0.2) but Android code still uses legacy approach

Why Did This Happen?

React Native Changes: Recent versions enforced stricter @nonnull checks
Library Updates: Version 7.0.0 update primarily addressed iOS privacy policy compliance; Android code was not updated
Compatibility Issues: Worked in older React Native versions but causes crashes in newer versions

Problem Code Location
File: node_modules/react-native-zip-archive/android/src/main/java/com/rnziparchive/RNZipArchiveModule.java
Lines: 67, 82, 110, 125, 177, 215, 277, 341, 347, 363, 413, 420 (12 locations total)

Example:

// ❌ Incorrect Code (null is not allowed!)
catch (Exception ex) {
  promise.reject(null, ex.getMessage());
  return;
}

🔧 Patch Details
Changes Made
Modified all 12 instances of promise.reject(null, ...) → promise.reject("E_ZIP_ERROR", ...)

// ✅ Modified Code (error code added)
catch (Exception ex) {
  promise.reject("E_ZIP_ERROR", ex.getMessage());
  return;
}

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