javascript-obfuscator / react-native-obfuscating-transformer

Obfuscation for React Native bundles
MIT License
196 stars 100 forks source link

com.facebook.react.bridge.NoSuchKeyException: lineNumber #14

Closed mppperez closed 3 years ago

mppperez commented 5 years ago

Hello,

unfortunately I'm getting an NoSuchKeyException when trying to start my application on android after obfuscating the javascript code:

com.facebook.react.bridge.NoSuchKeyException: lineNumber at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:122) at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:126) at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:180) at com.facebook.react.util.JSStackTrace.format(JSStackTrace.java:28) at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54) at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) at android.os.Looper.loop(Looper.java:164) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) at java.lang.Thread.run(Thread.java:764)

I've tracked the error down: it is caused if the MainComponent is obfuscated as well (registered in index.js via "AppRegistry.registerComponent(...))".

I couldn't find anything in the docs: is it not possible to obfuscate the main component as well? Anyone maybe has a hint how this could be done?

My configuration:

rn-cli.config.js module.exports = { transformer: { babelTransformerPath: require.resolve("./transformer") }, };

transformer.js

const obfuscatingTransformer = require("react-native-obfuscating-transformer");

const filter = filename => { return filename.startsWith("app") && !filename.startsWith("app/components/index"); // necessary for now due to NoSuchKeyException };

module.exports = obfuscatingTransformer({ / Insert here any required configuration / filter: filter, obfuscatorOptions : { compact: true, controlFlowFlattening: false, deadCodeInjection: false, debugProtection: false, debugProtectionInterval: false, disableConsoleOutput: true, identifierNamesGenerator: 'hexadecimal', log: false, renameGlobals: false, rotateStringArray: true, selfDefending: false, stringArray: true, stringArrayEncoding: false, stringArrayThreshold: 0.75, unicodeEscapeSequence: false }, trace: true, enableInDevelopment: true });