proguardreact-nativeandroid-proguardfetch-api

Fetch API not working with Proguard


The fetch API does not work when proguard is turned on. Below is the code snippet

try {
const response = await fetch(url, {
      method: 'GET',
      headers: {
        'Content-Type': "application/json",
        'Accept': 'application/json'
      }
    });    
} catch (err) {
  console.log(err)
}

I am able to trace the debugger till the fetch call. But after that there is neither error nor response. No errors/warnings in console as well. Any help on how to debug/solve this is much appreciated.

Im using RN v0.55.4 (latest)


Solution

  • Added the below proguard rule to fix this

    -optimizations !method/*/*,!code/*/*