Build and install unsigned apk on a device without a development server?

As I am new to reaction-native, so if something is wrong in steps, let me know.

I created a responsive native Android application using the command as per the documentation

responsive native android

during operation on the device, the following command was used

react-native android launch

which gives me the output of 2 apk files in my project folder / android / app / build / output / apk

enter image description here

Now, when I use this apk after installation to install, it requests the development server to connect to bundle JS. But my requirement is that the user does not need to deal with the development server, he just needs to install apk, and everything is ready.

Some questions went over at https://stackoverflow.com/a/3/92922/ ... but they did not help to create an unsigned apk that does not require a development server.

Could you guys help me find a way in which how to build and unsigned apk in responsive native?

+124
android react-native apk
Feb 09 '16 at 4:33
source share
12 answers

You need to manually create a package for debug build.

Bundle debug build:

#React-Native 0.49.0+ react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug #React-Native 0-0.49.0 react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug 

Then build the APK after bundling:

 $ cd android #Create debug build: $ ./gradlew assembleDebug #Create release build: $ ./gradlew assembleRelease #Generated 'apk' will be located at 'android/app/build/outputs/apk' 

PS Another approach may be to modify Gradle scripts.

+197
Apr 30 '16 at 10:40
source share

Please follow these steps.

Put your JS:

if you have index.android.js in the root of the project, run

 react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug 

if you have index.js in the root of the project, run

 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 

Create Debug Apk:

 cd android/ ./gradlew assembleDebug 

Then you can find your apk here:

 cd app/build/outputs/apk/ 
+79
Feb 10 '17 at 9:33
source share

The following commands are launched with me in the project directory.

To react to the old version (you will see index.android.js in the root):

 mkdir -p android/app/src/main/assets && rm -rf android/app/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 && cd android && ./gradlew clean assembleRelease && cd ../ 

To respond to the new version (you just see index.js in the root):

 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 ../ 

The apk file will be generated at:

  • Gradle <3.0: android / application / assembly / outputs / apk /
  • Gradle 3. 0+: android / application / assembly / outputs / apk / release /
+28
Aug 29 '17 at 3:59 on
source share

Last update

In your project root directory

Make sure you already have the android / app / src / main / assets / directory, if you do not create a directory, then create a new file and save it as index.android.bundle and put your file as this android / app / src / main / assets / index.android.bundle

After that run

 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 assembleDebug 

Then you can get apk in app / build / output / apk / debug / app-debug.apk

+15
Jun 10 '19 at 5:03
source share

After you complete the first answer, you can launch your application using

 react-native run-android --variant=debug 

And your application will work without the need for a package

+6
Dec 03 '17 at 12:37 on
source share

For a Windows user, if all the steps follow properly from this: https://facebook.imtqy.com/react-native/docs/signed-apk-android.html

You only need to run: gradlew assembleRelease

And your file will be:

  • application-release.apk
  • application release-unaligned.apk

Location: E:\YourProjectName\android\app\build\outputs\apk

+3
Jan 02 '17 at 7:15
source share

I react to the native 0.55.4, basically I had to manually bind:

 react-native bundle --dev false --platform android --entry-file index.js --bundle- output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets- dest ./android/app/build/intermediates/res/merged/debug 

Then connect the device via USB, enable USB debugging. Check the connected device using adb devices .

Finally, run react-native run-android which will install debug apk on your phone, and you will be able to run it normally with the dev server

Remarks:

  • Starting at 0.49.0, the entry point is one index.js
  • gradlew assembleRelease only generates release unsigned apks that cannot be installed
+2
Jun 17 '18 at
source share

It may be possible to create an unsigned version of the apk for testing so that you can work on your mobile phone.

I initially got red screen errors, as most were mentioned here. but I followed the same thing mentioned here and it worked for me.

On your console from the working directory, run these four commands

 react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug cd android gradlew assembleDebug gradlew assembleRelease 

And then the APK file will produce on: android \ app \ build \ output \ apk \ debug \ app-debug.apk

+2
Dec 22 '18 at 23:07 on
source share

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.

+2
Sep 10 '19 at 15:28
source share

In case someone else has recently encountered the same problem, I am using React Native 0.59.8 (also tested with RN 0.60) and I can confirm some other answers, here are the steps:

  1. Uninstall the latest compiled version of your application installed on your device.

  2. Run 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

  3. run cd android/&&./gradlew assembleDebug

  4. Download your app-debug.apk to the android / app / build / output / apk / debug folder

good luck!

+1
Jun 17 '19 at 13:47 on
source share

I found a solution that changes buildTypes as follows:

 buildTypes { release { signingConfig signingConfigs.release } } 
0
Jun 29 '19 at 15:40
source share

Go to the android folder and run ./gradlew assembleRelease to create a release file that you can send to your Android device. The apk version does not require the dev server to work.

-one
Feb 09 '16 at 7:51
source share



All Articles