JavaScript can also interface with Native Java modules. Java is compiled and embedded in the APK as one or more classes.dex file(s). A tool such as ByteCode viewer can decompile the classes.dex to reveal sensitive IP within Java source:
Leaving code exposed in such a way is quite dangerous. A hacker could clone the app, infiltrate back-end systems, initiate a data breach, and more. Luckily, PreEmptive can protect the code embedded in the APK. JSDefender for JavaScript can protect the JavaScript bundle. DashO Java obfuscator can protect the Java code.
JSDefender’s Metro plugin and DashO’s Gradle plugin integrate protection directly into our build.
metro.config:
build.gradle:
When building the React Native project
>npx react-native run-android
or
>gradlew clean assembleRelease or bundleRelease
PreEmptive can be seen running in the build output:
After this build, the binary is hardened against decompilation, reverse engineering, and tampering:
The complete source code sample can be downloaded here.
To run the sample: