1

I have a React Native project with about 3 or 4 screens.

After I decompiled the generated Android classes.dex file, I only found two Java classes. If I'm correct that React Native compiles your components to native Android classes, where are all the Android classes for those screens?

enter image description here

Please note: The APK was bundled correctly as it runs fine on Android devices.

Also I ran the following command to create the APK:

react-native bundle --platform android --dev false --entry-file index.js \
            --bundle-output android/app/src/main/assets/index.android.bundle \
            --assets-dest android/app/src/main/res/

Thanks!

Adrian Bartyczak
  • 322
  • 2
  • 11

2 Answers2

1

React Native will not compile your components to native Android classes.

Here is a similar question:

Does React Native compile JavaScript into Java for Android?

Shree
  • 18,997
  • 28
  • 86
  • 133
maltoze
  • 473
  • 3
  • 10
0

First, you have to install APKTOOL, then you have to unzip apk, and then you have to decompile js code as follow below

installation of apktool

For Macbook

brew install apktool

For Linux

apt-get install -y apktool

For Window

you can read installion step for window DOCS

Usage

after install apktool, unzip apk file by run this command on terminal like this:

apktool  d /pathOfApkFile.apk

After that you will get index.android.bundle file at pathOfApkFile/assets/index.android.bundle

than you can use react-native-decompiler for decompile index.android.bundle file

Decompile index.android.bundle File

you can decompile index.android.bundle by run this command

npx react-native-decompiler -i ./index.android.bundle -o ./output

after that, you will get JS decompiled file in ./output directory

Muhammad Numan
  • 12,108
  • 1
  • 25
  • 50