ubuntu下搭建cordova开发环境
http://levi.cg.am/archives/3587(看这篇就够了)
不!
这篇写得更好:http://aguegu.net/?p=1822
Cyper实战:
将android加入环境变量
$ vi ~/.bashrc
#AndroidDev PATHexport PATH=${PATH}:~/android/android-sdk-linux/toolsexport PATH=${PATH}:~/android/android-sdk-linux/platform-tools
$ source ~/.bashrc
1. Install Apache Cordova with npm
$ sudo npm install -g cordova
...
/usr/local/bin/cordova -> /usr/local/lib/node_modules/cordova/bin/cordova
cordova@4.0.0 /usr/local/lib/node_modules/cordova
2. Create a Cordova app and cd to the new folder
$ mkdir -p ~/cordova/projects/helloworld
$ cd~/cordova/projects/helloworld
$ cordova create hello com.example.hello "Hello World"
$ cd hello/
3. Add Android as a cordova platform
$ cordova platform add android
如果出现错误Error: Please install Android target "android-19".
则先输入android打开SDK Manager勾选Android4.4.2(API 19)下面的SDK Platform和ARM EABI v7a System Image)
Creating android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.example.hello
Name: Hello World
Android target: android-19
Copying template files...
Project successfully created.
$ sudo apt-get install ant
然后ant就装好了。which ant --> /usr/bin/ant --> /usr/share/bin/ant
(如果不安装ant执行接下来的cordova emulate或build命令会报错:
Failed to run "ant -version", make sure you have ant installed and added to your PATH.)
4. Create an Android emulator
$ android create avd -n hello -t 1
Auto-selecting single ABI armeabi-v7a
Android 4.4.2 is a basic Android platform.
(-n指定avd的名称,-t指定target level,可以通过android list targets来显示目前有哪些api level)
5. Run the cordova app on the emulator
$ cordova emulate android
半天没反应
$ emulator -avd hello或者emulator @hello
Segmentation fault (core dumped)
我是这么做的,先开个terminal执行emulator-arm @hello打开模拟器,
然后呢直接cordova run android
Build an APK package
$ cordova build
BUILD SUCCESSFUL
Total time: 28 seconds
Built the following apk(s):
/home/cyper/cordova/projects/helloworld/hello/platforms/android/ant-build/CordovaApp-debug.apk
更多相关文章
- [Android(安卓)学习笔记] 判断 Android(安卓)设备是否为模拟器
- 关于 android RIL 调试
- android模拟器设置代理上网
- Ubuntu搭建Android交叉编译环境
- 启动emulator出错
- react-native android 环境配置
- Android开发(一)拨打电话程序
- Android-中常用方法集锦
- 从android模拟器中提取文件系统