Detailed explanation of Android native embedded react native

1. First integrate the project directory

I use the format of react native init project to import directly, that is, my android project directory is similar to node_ Modules is in a directory.

After we init the project, the project initialization is completed. At this time, we can directly run the project with the command react native run Android. As for how to debug, we have already said before.

Let's talk about how to separate development and operation. We usually choose webstrom for development. After development, we will separate the compilation of Android and IOS.

Start NPM

Let's talk about Android embedded RN environment.

Write Android native code to call RN

Note that some permissions such as network should be added.

Create package JSON, add react native package

Use the command NPM init, just follow the steps, and give you a screenshot:

Finally, you can see a package in your RN project json。

Run demo

Note: Java. Net may appear Lang. runtimeException: could not get batchedbridge, make sure your bundle is packaged correctly, react native bundle - platform Android - Dev false - entry file index android. js ―bundle-output ReactDemo/app/src/main/assets/index. android. bundle ―sourcemap-outpu ReactDemo/app/src/main/assets/index. android. map ―assets-dest ReactDemo/app/src/main/res/

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>