Taro如何打包Android apk?

首先,我们使用使用命令创建模板项目,创建的命令如下。

taro init myApp

然后,使用 yarn 或者 npm install安装依赖包,并使用下面的命令编译Taro项目。

yarn dev:rn

启动后会开启一个监听的进程。

不过,细心的你可能会发现,使用taro init命令初始化的项目是没有原生模块支持的,原来Taro使用了一个壳子工程,首先使用下面的命令下载壳子工程taro-native-shell,如下所示。

git clone [email protected]:NervJS/taro-native-shell.git

在taro-native-shell个目录使用 yarn 或者 npm install 安装依赖,并使用下面的命令启动壳子工程。

react-native run-android

不过,启动后报了如下的错误:

error: bundling failed: NotFoundError: Cannot find entry file index.js in any of the roots: ["/Users/mac/Taro/work/taro-yanxuan"]
    at DependencyGraph.getAbsolutePath (/Users/mac/Taro/work/taro-yanxuan/node_modules/metro/src/node-haste/DependencyGraph.js:317:11)
    at /Users/mac/Taro/work/taro-yanxuan/node_modules/metro/src/DeltaBundler/DeltaCalculator.js:280:416

你可能感兴趣的:(文章,apk,android,ios)