Starting with version 0.57, none of the previously provided answers will work anymore, since the directories in which gradle expects to find the package and the assets have changed.
A simple way without a responsive native ligament
The easiest way to build a debug build is to not use the react-native bundle command at all, but simply modify your app/build.gradle .
Inside the project.ext.react map in app/build.gradle add the entry bundleInDebug: true . If you want this to not be a --dev assembly (without warnings and a minimized package), you should also add the devDisabledInDebug: true entry to the same card.
Reactive ligament
If for any reason you need or want to use the react-native bundle command to create the package, and then ./gradlew assembleDebug to create the APK with the package and assets, you should definitely put the package and assets in the correct paths where gradle can them to find.
Starting with version 0.57, these android/app/build/generated/assets/react/debug/index.android.js for the bundle
and android/app/build/generated/res/react/debug for assets. So, the complete commands for manually combining and assembling the APK with the package and assets:
react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/generated/assets/react/debug/index.android.bundle --assets-dest ./android/app/build/res/react/debug
and then
./gradlew assembleDebug
Package and Asset Path
Note that the paths where gradle searches for the package and assets are subject to change. To find out where these paths are, look at the react.gradle file in your node_modules/react-native directory. Lines starting with def jsBundleDir = and def resourcesDir = indicate the directories in which gradle looks for the package and resources, respectively.
TheBaj Sep 10 '19 at 15:28 2019-09-10 15:28
source share