This is the 14th day of my participation in the August More Text Challenge. For details, see: August More Text Challenge

Personal environment trample pit

Install Java Development Kit (JDK)

1, 64-bit, download JDK X64, 32-bit download x86

2, can be installed in other disk, do not need to be installed in C drive

3. In the system variables of advanced environment variables, add ANDROID_HOME and JAVA_HOME, and enter the JDK installation path

ANDROID_HOME%\platform-tools, %ANDROID_HOME%\emulator, %ANDROID_HOME%\tools, %ANDROID_HOME%\tools, %ANDROID_HOME%\tools % ANDROID_HOME % \ tools \ bin)

Installing the Python environment

Install 2.x version, do not need to install 3.x version, there is no exquisite, always determined

Install the android – studio

1. Click Settings in File,

2. Select the Android SDK from the Systeam Settings inside Appearance & Behavior, and then set the Android SDK Location in Android SDK Location

\

Go to Next, Next, then install the environment, and finally Finish

3. After the installation environment

Android Platform 29, Sources for Android 29 Inter x86 Atom_64 System Image

In SDK Tools, first click Show Package Details, then select Android SDK build-Tools version 29.0.2

When you’re done, click Apply, confirm the environment, and select I agree to start installing the Android environment

Finally click OK and the Environment page is completed successfully

\

Ex: check whether the physical phone is connected -> ADB Devices

First, reference the tutorial, build the environment

Address: this tutorial reactnative. Cn/docs / 0.48 / g…

Refer to the video tutorial, there are several differences:

(Video tutorial: ke.qq.com/webcourse/i…)

  1. Chocolatey does not need to be installed.

  2. Skip personalization and go directly to Configure -> SDK Manager on the welcome screen (which can also be opened later in File -> Settings on the software interface).

Just check the following three options to install.

\

Use the simulator debugging and error reporting

1, Your CPU do not support NX. Unfortunately, Your computer does not support hardware accelerated virtualization.

Start the emulator on Android Studio and keep it started.

【 Solution 】

To add the emulator, select Other Images and select the ABI of ARM (arm64 must be used for 64-bit systems)

\

2, Unable to load script from assets ‘index.android.bundel’. Makve sure your bundel is packaged corredtly or you’re running a packager server.

[Other solutions]

1, (in the project directory) mkdir android/app/SRC/main/assets

2, 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

3, the react – native run – android

Stackoverflow.com/questions/4…

Just make sure you have both files in the following path:

\

3, Excecution failde fro task ‘: app: complieDebugJavaWithJavac’. Could not find the tools. The jar.

[Cause] When you install the Java package, you have to choose the JDK and JRE paths twice. If you select the same JDK and JRE paths, the JRE package will overwrite the JDK. The tools.jar and dt.jar packages are not found.

[Solution]

During the installation, install the JDK and JRE in different files. For example, install the JDK under D :/ Java/JDK and the JRE under D :/ Java /jre.

\

4, could not connect to the development server

[Solution]

In the emulator, press Ctrl+M to open the Debug tool (Dev Settings), click Debug Server Host & Port for Device and set it to localhost:8081.

My new project was solved by the above method, but the project developed by another company still hasn’t been solved and has been stuck here.

5, the Commandyarn add react-native --exact failed.

Re-register the image address

npm config set registry registry.npm.taobao.org

npm config set disturl npm.taobao.org/dist

\

6. Application XXX has not been registered

[Solution]

Inexplicably ok…

\

7, Process system isn’t responding, Close app or Wait? Click on both buttons and nothing happens.

[Solution]

Open the Android folder in your project in Android Studio, wait a few minutes for the compile process, and if prompted to update the Gradle plug-in, update it immediately, then click Run and select the corresponding emulator.

This screen will also appear when the emulator is opened, but click Close app to run the program and use it normally.

Tragedy yes, and then it opened again, and this happened again.

“This is a common problem on the simulator. It means that the system process is not responding. It is usually because the simulator is running too slowly and the system cannot start. Suggest a better computer.”

Let’s ditch the simulator and switch to the real thing…

\

8. Module HMRClient is not a registerd callable Module

[Solution]

Set the correct IP in Dev Setting. Refer to the article: www.jianshu.com/p/fbcce5159…

The problem is THAT I don’t know what the right IP is!

\

Author: gzfgeh

Link: www.jianshu.com/p/fbcce5159…

Source: Jane Book

The copyright belongs to the author. Commercial reprint please contact the author to obtain authorization, non-commercial reprint please indicate the source.

\

Tips:

Create a version of the React-Native project

React-native init MyApp –version 0.44.3 (Note that the version number must be accurate to two decimal points.)

2. Modify the App name

If you do not change the app name when you package it, the app name will be the same as the name you set in react-native init. How to change it?

Step1: we open the project of the android/app/SRC/main/AndroidManifest. The XML file can see the name of the set:

This means that the app display name is set in @string/app_name.

Step2: that we continue to directly open the android/app/SRC/main/res/values/strings. The XML, you can see app_name, in this configuration can be changed to what you want, such as:

\

3. Modify the address and port of the simulator debugging service, and how to run multiple React Native projects simultaneously

Blog.csdn.net/fengyuzheng…

Optimize Android Studio

Bbs.itheima.com/thread-2042…

Applying for large memory

installation path\studio64.exe.vmoptions or studio.exe.vmoptions

Open with a text editor and find the first two lines, as shown below

-Xms128m

-Xmx750m

Modify the minimum and maximum values. You are advised to

-Xms256m

-Xmx2048m

Three, the use of Android real machine debugging and error

(1) Configuration Procedure:

Reference: reactnative. Cn/docs / 0.50 / r…

Configuration run:

1. Open the /android/ SDK /platform-tools folder in the ANDOID_HOME environment variables folder and run adb reverse TCP :8081 TCP :8081

2, set the phone: developer options – USB debugging – check

3. Connect the mobile phone to the computer through USB, and run the command ADB Devices on the computer to check whether it is connected.

4. Open the project and run react-Native run-Android to install and open the APP on the mobile phone (the running method I is recommended).

Operation method two:

1. Open the Android folder in the project in Android Studio, wait a few minutes for the compile process, if the prompt to update gradle plug-in, then immediately update.

2. Click Run and Select the corresponding equipment in the Select Deployment Target dialog box to operate on the real machine.

\

(2) Error report and solution

Android Studio is connected to the Real Android machine, but the device cannot be found

[Solution]

1. When the mobile phone is connected to the computer, it automatically connects to the mobile assistant, which causes ADB to be occupied, so that AS cannot detect the device. Just shut down the process of the mobile assistant.

2. If the ADB tool is unavailable or abnormal, run the following command to shut down and restart the ADB service:

adb kill-server

adb start-server

Tips: List the devices currently connected to your computer:

adb devices

3. The other solution reference www.zhihu.com/question/30…

\

Device supports, but APK only supports Armeabi-V7a, x86

[Solution]

1. Restart Android Studio

2. Delete the build.gradle file in the Android -> App folder of the project

ndk {

    abiFilters “armeabi”, “armeabi-v7a”, “x86”

}

Refer to the article: stackoverflow.com/questions/4…

\

3, Could not connect to the development server

[Solution]

Click the menu or shake the phone. After Dev Settings, click Debug Server Host & Port for Device and set it to localhost:8081.