Ionic开发指南-第二章 安装Ionic

在这一章,我们将要了解Ionic的下载和安装过程中所有必需的依赖关系。

选择平台

首先,我们需要首先注意使用最新稳定版的的Ionic构建应用程序的最低要求。Ionic目标最新的iPhone和Android设备。我们支持iOS6 +,和Android 4.0 + (尽管2.3应该可以运行)。然而,因为有很多不同的Android设备,某些人可能无法正常运行。像往常一样,我们正在寻找帮助测试和改进我们的设备的兼容性和希望帮助社区GitHub上项目。
您可以在您喜欢的任何操作系统上使用Ionic开发应用程序。事实上,Ionic在Mac OS X,Linux和Windows上都能进行开发。然而,为了遵循这个指南,现在你需要使用命令行,同时为了可以开发iPhone APP,你必须有OS X来开发和部署应用程序,所以 建议最好选择 OS X。
如果你在Windows上,一定要下载并安装Git for Windows和选择Console2。您将在Git Bash or Console2  窗口中 执行指南中任何命令。

首先,我们将去安装最新版本的Apache Cordova,将我们的应用程序打包成一个传统的本地应用。

安装Cordova,确保你安装node.js,然后运行。

$ sudo npm install -g cordova
如果在Windows上运行去掉命令sudo。根据你的开发平台,你将需要安装特定于平台的工具。遵循Cordova for Android和iOS平台指导,以确保你拥有 在这些平台上开发的一切所需的。幸运的是,你只需要做一次。

Linux Android 

如果您正在运行一个64位版本的Ubuntu,你需要安装32位的库,Android目前只有32位。

$ sudo apt-get install ia32-libs

Windows 安装JAVA,Ant,Android

Windows用户开发Android:你要确保你有下面的安装和设置。

注意:当您更改PATH,或任何其他环境变量,您需要重新启动或打开一个新标签在您的shell程序的PATH更改生效。

Java JDK

安装最新版本的JDK和JRE

下一步,创建JAVA_HOME环境变量,目标为java安装的根目录。如果你安装的 JDK 路径为 C:\Program Files\Java\jdk7, 设置为 JAVA_HOME 的值. 同时, 也将JDK的 bin 目录 添加到PATH 环境变量中。

最后,完整的路径 为% JAVA_HOME % \ bin或者C:\Program Files\Java\jdk7\bin。

Apache Ant

安装 Ant,点击 下载,解压,降低一个文件夹移动到安全的目录下,同时将 bin 路径添加在PATH环境变量中。 如果你将 Ant 目录放到 c:/下, 那么PATH: C:\apache-ant-1.9.2\bin

Android SDK


安装Android SDK也是必要的。Android SDK提供了你所需的API库和开发工具构建、测试和调试Android应用程序。

科尔多瓦需要ANDROID_HOME环境变量设置。这应该指向[ANDROID_SDK_DIR]\ sdk目录(例如c:\ android \ sdk)。

接下来,更新你的路径包括工具/平台工具/文件夹,文件夹中。使用ANDROID_HOME,您将添加两个% ANDROID_HOME %和% ANDROID_HOME % \ \工具平台工具。

安装Ionic

Ionic有一个方便的命令行实用程序开始,构建,和打包Ionic的应用。

要安装它,只需运行:

$ sudo npm install -g ionic

创建项目

现在,我们需要使用Cordova创建一个新的项目:

$ ionic start todo blank

将创建一个名为todo的文件夹目录中运行的命令。接下来,我们将进入该目录:

$ cd todo

如果您计划使用任何版本控制系统,您可以继续使用这个新文件夹设置它。为新的应用程序,遵循这个文件夹结构快速地启动和运行:

配置平台

现在,我们需要告诉Ionic,我们想使iOS和Android平台。注意:除非你是在Mac OS,那就不要使用iOS平台:

$ ionic platform ios
$ ionic platform android

如果你看到错误在这里,一定要按照上面的平台指导安装必要的平台工具。

Android on OS X

如果你得到这个错误:[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.],然后尝试运行这个命令之前,先添加android平台:

$ export JAVA_HOME=$(/usr/libexec/java_home)

测试

只是为了确保默认的项目工作,试着构建和运行项目(用ios代替android构建android):
$ ionic build ios
$ ionic emulate ios

开始吧!

现在我们已经准备好开始构建应用程序,所以继续到下一个章节



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Learning Ionic 2 - Second Edition by Arvind Ravulavaru English | 4 May 2017 | ASIN: B01BGV25GS | 378 Pages | AZW3 | 10.51 MB Create real-time hybrid applications with the leader of HTML5 frameworks: Ionic Framework About This Book Step into the world of amazingly interactive and real-time app development using Ionic 2 Leverage the powerful Angular 2 along with Ionic to develop cutting edge apps Detailed code examples and explanations will help you get up and running with Ionic quickly and easily Who This Book Is For This book is for JavaScript developers with basic skills. No previous knowledge of Ionic is required for this book. What You Will Learn Understand the workings of the mobile hybrid architecture Transform the single page template to a multi-page template using components such as Tabs Integrate Ionic API components in your app Theme Ionic apps as well as customize components using Ionic SCSS support Design and build an app that involves both device features as well as third-party integration Deploy the Ionic apps to stores and manage their subsequent releases Perform unit testing, end to end testing, and device testing on your apps In Detail Ionic makes it incredibly easy to build beautiful and interactive mobile apps using HTML5 and AngularJS. Ionic 2 represents that collective learning about how to make the web do more on mobiles. Ionic 2 not only makes app development easier and faster, but also makes it more fun. This hands-on guide will help you understand the Ionic framework and how you can leverage it to create amazing real-time applications with exciting interactive features. We begin by covering the essential features of Angular 2 and then dive straight into how Ionic fits in today's world, providing you with a good understanding of the mobile hybrid architecture along the way. Further on, you will learn how to work with Ionic components, allowing you to build layouts using Ionic framework, be it single page or multi-page. We take a look at theming Ionic apps using the built-in SCSS setup, work with Ionic API components, and create a “Thought Journal” app that needs session and data to be managed on the client side. After that, we explore Cordova and ngCordova and you will learn how to integrate device-specific features through a food allergy notification app. Lastly, you will learn to test the apps that you have built so far, migrate existing Ionic 1 apps to Ionic 2, and deploy them to the App Store. By the end of this book, you will be able to develop hybrid mobile applications from start to finish.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值