58

I've seen new release of react native for android and tried some examples. It works only with USB debug mode and "adb reverse tcp:8081 tcp:8081". How can I build android app for "production" including all dependencies and without react web-server connections. Thank you.

1
  • did the solutions work for you? That process produces an unsigned apk for me, any pointers? Commented Apr 13, 2016 at 17:12

5 Answers 5

73

To build a release version of your Android app:

$ cd your-app-folder
$ cd android && ./gradlew assembleRelease

You'll need to set up signing keys for the Play Store, full documentation here: https://reactnative.dev/docs/signed-apk-android

Sign up to request clarification or add additional context in comments.

7 Comments

Thank you. Waiting for better tools to do it. Correct me if I am wrong, for build release .apk there is no tools yet ?
from root-app directory try this cd android && ./gradlew assembleRelease . As per new documentations, facebook.github.io/react-native/docs/signed-apk-android.html
@Martin thanks for that, but I seem to still have trouble with that, that process generates an unsigned apk for me, any idea what I'm doing wrong?
You need to sign it leveraging your keystore. Look over this - facebook.github.io/react-native/docs/…
@martin-konicek, this solution only generated an app-release-unsigned.apk which i tried installing but didn't install. Anything in particular known to cause this? Thanks
|
28

You will have to create a key to sign the apk. Use below to create your key:

keytool -genkey -v -keystore my-app-key.keystore -alias my-app-alias -keyalg RSA -keysize 2048 -validity 10000

Use a password when prompted

Once the key is generated, use it to generate the installable build:

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

Generate the build using gradle

cd android && ./gradlew assembleRelease

Upload the APK to your phone. The -r flag will replace the existing app (if it exists)

adb install -r ./app/build/outputs/apk/app-release-unsigned.apk

A more detailed description is mentioned here: https://facebook.github.io/react-native/docs/signed-apk-android.html

1 Comment

folder structure is updated, use adb install -r ./app/build/outputs/apk/release/app-release.apk to install on phone
17

As for me, I add in my package.json to "scripts":

"release": "cd android && ./gradlew assembleRelease"

And then in terminal I use:

npm run release

Or with yarn:

yarn release

Comments

5

I have put together some steps that worked for me. Hopefully it would save time.

For bundling the package to work in local you need to do

$ curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

Then for compiling apk

$ ./gradlew assembleRelease

I have added detailed instructions at : https://github.com/shyjal/reactnative-android-production

Comments

0

To create a bundle of your android application to release application on play store.

cd /android
sudo ./gradlew bundleRelease

go to the android/build/outputs/bundle/release/app-release.apk

Upload this bundle on play store console.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.