Reactnative How to play the debug version of the installation package (Android)

Source: Internet
Author: User

Recently by the automatic group of Sister Chase to ask Reactnative Debug version of the installation package for automated testing, what?? Debug Version package?

Never heard of it, OK ....


Always thought that debug debugging only need to connect the phone with USB to the computer and then execute the command: react-native run-android debugging is good, which know that there is this little thing, since to engage in it to start research it!


I. reactnative pack apk (version android )


Official react native Pack apk for reference official documents:

Http://reactnative.cn/docs/0.49/signed-apk-android.html#content

The basic steps for official packaging are divided into these steps:

The first thing to install the evil Android SDK, this is the need for scientific Internet (is to turn the wall) Oh!

1. Generate a signature key file (one app is generated only once)2. Set the Gradle variable (put the signature file generated by the first step into the project and configure the Gradle information)3. Add the Gradle configuration file signed to the project4. Build the release APK package (execute command in the project's Android directory:./gradlew assemblerelease)

After performing the 4th step, you can generate a departure line package such as:

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/A7/14/wKioL1ngWvTCFkXkAAGdQdXX2n0140.jpg-wh_500x0-wm_ 3-wmp_4-s_1668882417.jpg "title=" blogn1.jpg "width=" "height=" 361 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 300px;height:361px; "alt=" Wkiol1ngwvtcfkxkaagdqdxx2n0140.jpg-wh_50 "/>


Two. reactnative Development debug Real Machine Debug

Please refer to the documentation for details: http://reactnative.cn/docs/0.49/running-on-device-android.html#content

the: You may encounter white screen when running on a real machine, please locate and turn on悬浮窗权限. such as the setup of the MIUI systemAt this point.


1. First connect the phone with the computer, pop up figure A, then click on the USB option that pops up, select "Transfer file (MTP)" B:


figure a:650) this.width=650; "Src=" Https://s2.51cto.com/wyfs02/M02/08/5E/wKiom1ngYF2C2OoQAALu6c_ulHU821.jpg-wh_ 500x0-wm_3-wmp_4-s_441432805.jpg "title=" blogn2.jpg "width=" 213 "height=" 380 "border=" 0 "hspace=" 0 "vspace=" 0 "style= "width:213px;height:380px;" alt= "wkiom1ngyf2c2ooqaalu6c_ulhu821.jpg-wh_50"/> Figure B:650) this.width=650; "src = "https://s3.51cto.com/wyfs02/M00/A7/14/wKioL1ngXgLCxDpGAAGeB5eJ4eI365.jpg-wh_500x0-wm_3-wmp_4-s_4282731007." JPG "title=" blogn3.jpg "width=" 226 "height=" 310 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:226px;height:310px; " alt= "Wkiol1ngxglcxdpgaageb5ej4ei365.jpg-wh_50"/>


2. After the phone is connected successfully, switch the console directory to the Android directory and execute the command: react-native run-android

Command execution will open a background window (automatically open a server, let's name this window mydog ), but also on your phone to install the debug version of the installation package, after the installation is complete can be debugged ....

Big Egg:

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/A7/14/wKioL1ngYXmAQk_VAAF--8xPFtE475.png-wh_500x0-wm_ 3-wmp_4-s_2019336898.png "title=" Blogn4.png "width=" 168 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 168px;height:300px; "alt=" Wkiol1ngyxmaqk_vaaf--8xpfte475.png-wh_50 "/>

After installation you shake your phone will have magical effect, of course, to view console output, on this Magic effect page click on "Debug JS remontely", will automatically open the browser, follow the browser prompts to see the console information.



Three. reactnative hit the debug version of the APK installation package

Hit the debug version of the installation package, similar to the second step.


Debug debugging needs to connect to the computer to open a server, is the second step of the Auto-open window mydog, if made into a package, you need to manually generate a bundle file, so that you no longer need to open the server window (to be called into a package, Where to get this window), like the following command to generate the bundle file:

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/

Please execute this command under Android's parent directory (please configure your .../.../src/main/assets/... Directories and ..../src/main/res) My directory is as follows:

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/A7/16/wKioL1ngbayCMoY0AAIR-uzzn3U832.jpg-wh_500x0-wm_ 3-wmp_4-s_1075397509.jpg "title=" b1.jpg "width=" 262 "height=" 380 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:262px ; height:380px; "alt=" Wkiol1ngbaycmoy0aair-uzzn3u832.jpg-wh_50 "/>




after executing the above command, 2 kinds of things are generated, One is the bundle file, and the other is all the renamed static picture , the new name is the static picture of the storage path, the following 2 graphs:

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/A7/16/wKioL1ngahrxBeHgAAPVUg4Vsek678.jpg-wh_500x0-wm_ 3-wmp_4-s_641573612.jpg "title=" blogxtp.jpg "width=" 243 "height=" 380 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 243px;height:380px; "alt=" Wkiol1ngahrxbehgaapvug4vsek678.jpg-wh_50 "/>

The red file above is bundle file, the following red file is to package the picture.


Attention:

The resulting picture may not be in the drawable-xxxhdpi directory, it may be in the drawable-hdpi or drawable-mdpi directory, you will need to manually copy these images to the drawable-xxxhdpi directory.


The storage path of my static picture is:

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/08/5F/wKiom1ngbM_wwNUkAAIoX0JQmMo247.jpg-wh_500x0-wm_ 3-wmp_4-s_515377509.jpg "style=" width:232px;height:380px; "title=" blogtplj.jpg "width=" 232 "height=" 380 "border=" 0 " Hspace= "0" vspace= "0" alt= "wkiom1ngbm_wwnukaaiox0jqmmo247.jpg-wh_50"/>




After the correct execution of the command, and generate bundle files, picture files, again the phone and the computer connected to the "second step", after the implementation of the mobile phone installation of the app, will also generate a app-debug.apk package, this is our long-awaited debug installation package,

Well, finally, we can get a job with my sister!

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/A7/17/wKioL1ngcD2CKyiLAAEkB9-QlS0623.jpg-wh_500x0-wm_ 3-wmp_4-s_3838156480.jpg "title=" bend.jpg "width=" 391 "height=" 340 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 391px;height:340px; "alt=" Wkiol1ngcd2ckyilaaekb9-qls0623.jpg-wh_50 "/>


This article is from the "Big brown Bear It" blog, make sure to keep this source http://mamadu.blog.51cto.com/2662137/1972115

Reactnative How to play the debug version of the installation package (Android)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.