question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't make it work

See original GitHub issue

Hi I am trying to use this module. I created the rn-cli.config.js and transformer.js file in my project root folder and kept the default obfuscatingTransformer options (So module.exports = obfuscatingTransformer({})). But this doesn’t seem to work. The index.android.bundle file in the generated app-release.apk still remains unobfuscated (I performed a gradlew assembleRelease like usual to create the bundle before react-native run-android --variant=release) What am I doing wrong?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
AustinZunigacommented, Mar 6, 2020

I finally figured out how to make it work after several test.

my react and react native version:

 "react": "16.9.0",
 "react-native": "0.61.5",

install other dependencies needed:

npm install babylon --save
npm install --save babel-traverse

transformer.js

const obfuscatingTransformer = require("react-native-obfuscating-transformer")
const filter = filename => { 
  return filename.startsWith("src");
};

module.exports = obfuscatingTransformer({
// this configuration is based on https://github.com/javascript-obfuscator/javascript-obfuscator
  obfuscatorOptions:{
    compact: true,
    controlFlowFlattening: false,
    deadCodeInjection: false,
    debugProtection: false,
    debugProtectionInterval: false,
    disableConsoleOutput: true,
    identifierNamesGenerator: 'hexadecimal',
    log: false,
    renameGlobals: false,
    rotateStringArray: true,
    selfDefending: true,
    shuffleStringArray: true,
    splitStrings: false,
    stringArray: true,
    stringArrayEncoding: false,
    stringArrayThreshold: 0.75,
    unicodeEscapeSequence: false
  },
  upstreamTransformer: require('metro-react-native-babel-transformer'),
  emitObfuscatedFiles: false,
  enableInDevelopment: true,
  filter: filter,
  trace: true
})

metro.config.js

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
    babelTransformerPath: require.resolve("./transformer")   // add here the transformer.js
  },
};

NOTE:

set emitObfuscatedFiles to true in obfuscatorOptions to emit the obfuscated versions of files alongside their originals, for comparison.

If you’re building in release, you can also compare the generated index.android.bundle (located in \android\app\build\generated\assets\react\release) with and without using the react-native-obfuscating-transformer using online diff tool to see the difference

Read more comments on GitHub >

github_iconTop Results From Across the Web

Which is correct “I can't make it work” or “I can't make it to work”?
In “I can't make it work,” “work” is a verbal, a “bare” infinitive without the “to” sign, as is usual after “make”; in...
Read more >
Why Loving Someone Isn't Enough to Make It Work
Loving someone isn't enough to make it work. Ask yourself these 5 questions to know if your relationship has the potential to last....
Read more >
We Love Each Other But Can't Seem To Make It Work
We Love Each Other But Can't Seem To Make It Work. With Dr. Joe Beam. A More Realistic View Of An Amazing Relationship....
Read more >
I can't make it to work today. - WordReference Forums
"I can't make it to work today" means that you cannot attend your place of work, and it implies a journey. Perhaps your...
Read more >
when two people love each other and can't make it work is the ...
"when two people love each other and can't make it work is the real tragedy" | Loving two people, Words quotes, Quotes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found