2018.07.31 11:23

NativeScript vue 构建app程序

NativeScript vue 构建app程序,环境搭建和react-native的环境一样,需要java.android sdk 安卓模拟器,虚拟机启动安卓模拟器,(注:官方的那个环境搭建有很多坑不建议大家用那个去搭建,你会得到一大串的报错!!!)

安装 nativescript

npm install -g nativescript

nativescript -v 查看安装是否成功

NativeScript vue 构建app程序使用模板开始

$ npm install -g @vue/cli @vue/cli-init 
$ vue init nativescript-vue/vue-cli-template <project-name>
$ cd <project-name>
$ npm install


$ npm run watch:<platform>


本实例是在安卓模拟器下进行的执行 tns doctor

$ tns doctor
No issues were detected.
Your ANDROID_HOME environment variable is set and points to correct directory.
Your adb from the Android SDK is correctly installed.
The Android SDK is installed.
A compatible Android SDK for compilation is found.
Javac is installed and is configured properly.
The Java Development Kit (JDK) is installed and is configured properly.
Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
Component nativescript has 4.1.2 version and is up to date.

执行npm run watch:android

Administrator@lenovo-PC MINGW64 /e/jackieli/Nativescript Vue/demo
$ npm run watch:android

> demo@1.0.0 watch:android E:\jackieli\Nativescript Vue\demo
> npm run watch -- --env.android

> demo@1.0.0 watch E:\jackieli\Nativescript Vue\demo
> webpack --watch --env.tnsAction run "--env.android"

info: Copying NativeScript plugins to template dependencies...
info: Preparing NativeScript application from template...
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN demo@ No repository field.

info: Bundling application for android...

Webpack is watching the files…

Executing post-build scripts
info: Running NativeScript application...
Searching for devices...
Copying template files...
Installing tns-android
+ tns-android@4.1.3
added 1 package in 73.755s
Project successfully created.
Preparing project...
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin nativescript-vue for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared (Android)
Building project...
Gradle build...
     + setting applicationId
     + applying user-defined configuration from E:\jackieli\Nativescript Vue\demo\d                                                                                            ist\app\App_Resources\Android\app.gradle
     + adding nativescript runtime package dependency: nativescript-optimized-with-                                                                                            inspector
     + adding aar plugin dependency: E:\jackieli\Nativescript Vue\demo\dist\node_mo                                                                                            dules\tns-core-modules-widgets\platforms\android\widgets-release.aar
Checking the license for package Android SDK Build-Tools 27.0.3 in C:\Android\android-s                                                                                            dk\licenses
License for package Android SDK Build-Tools 27.0.3 accepted.
Preparing "Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)".
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" ready.
Installing Android SDK Build-Tools 27.0.3 in C:\Android\android-sdk\build-tools\27.0.3
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" complete.
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" finished.
Project successfully built.
Successfully installed on device with identifier ''.
Successfully transferred all files.