MaxToyberman / react-native-ssl-pinning

React Native ssl pinning and cookies handling based on okhttp3 on (Android). and AFNetworking on (iOS)
MIT License
346 stars 104 forks source link

E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules: Android App Crashed in Release Build #159

Open Akilramki opened 2 years ago

Akilramki commented 2 years ago

I am Getting Android App Crashes in Release Build ,if minifyEnabled is true and Call the Fetch Method in react-native-ssl-pinning, App Getting Crashed.

Error : java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference

android/app/build.gradle :-

def enableProguardInReleaseBuilds = true

buildTypes {
    release {
        signingConfig signingConfigs.debug
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

package.json "dependencies": { "react": "17.0.2", "react-native": "0.66.3", ..... .... "react-native-ssl-pinning": "^1.5.4", .... }

 App.js
 import { fetch } from 'react-native-ssl-pinning';

 fetch('URL', {
  method: POST,
  pkPinning: true,
  sslPinning: {
    certs: [key],
  },
  headers: {
    Accept:  'application/json',
    'Content-Type':  'application/json',
    Authorization: 'Bearer TOKEN' 
     },
})

Error: E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.package, PID: 6900 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference at com.toyberman.RNSslPinningModule.getDomainName(Unknown Source:11) at com.toyberman.RNSslPinningModule.fetch(Unknown Source:4) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148) at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0) at android.os.Looper.loop(Looper.java:257) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37) at java.lang.Thread.run(Thread.java:923)

Akilramki commented 2 years ago

Please check below link https://manuelrdsg.github.io/2019/06/secure-your-react-native-apps-before-production/

ChrisLombard777 commented 2 years ago

Same issue...

2022-08-31 10:10:17.890 22030-22101/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.payscan.africa, PID: 22030 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference at com.toyberman.RNSslPinningModule.getDomainName(Unknown Source:11) at com.toyberman.RNSslPinningModule.fetch(Unknown Source:4) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148) at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37) at java.lang.Thread.run(Thread.java:920) 2022-08-31 10:10:27.162 22160-22160/? D/ReactNativeFirebaseApp: received application context.

ChrisLombard777 commented 2 years ago

Followed all the instructions on: https://manuelrdsg.github.io/2019/06/secure-your-react-native-apps-before-production/

still crashing...

huandrey commented 1 year ago

@ChrisLombard777 did you solve it? I'm having the same problem right now :/

farellsujanto commented 7 months ago

I've fixed my issue on this error by sending JSON stringified body / sending undefined if the body is empty. This library can't seem to able process null body.

body: body ? JSON.stringify(body) : undefined,