2

I am using such command to generate an 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 && react-native run-android

Is it possible to edit this command to generate release APK?

lecham
  • 2,294
  • 6
  • 22
  • 41
  • 2
    Possible duplicate of [How can I generate an apk that can run without server with react-native?](https://stackoverflow.com/questions/35935060/how-can-i-generate-an-apk-that-can-run-without-server-with-react-native) – Vishal Dhanotiya Apr 06 '19 at 11:13
  • do you have android studio? if you have any experience with android studio there is a easy way to generate apk using that. if you had any experience tell me to share the guide – Amir Hedieh Apr 06 '19 at 11:52

3 Answers3

7

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 && cd android && ./gradlew clean && ./gradlew assembleRelease

./gradlew assembleRelease assembles all release builds (and generates release apk)

Your release build should be available under the following directory: [projectRoot]/android/app/build/outputs/apk/release/

user3764429
  • 402
  • 2
  • 12
1
  mkdir -p android/app/src/main/assets
 && rm -rf android/app/build 
&& 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 
&& cd android && ./gradlew clean assembleRelease && cd ../

I hope this will work for you…

Tanveerbyn
  • 764
  • 1
  • 10
  • 25
1
ORG_GRADLE_PROJECT_bundleInArRelease=true npx react-native run-android --variant Release

then you will find the APK inside ./android/app/build/apk/release/

I hope it helps you

MShokry
  • 81
  • 8