如何添加Android支持我的Ionic应用程序项目? [英] How to add Android support to my Ionic app project?

查看:198
本文介绍了如何添加Android支持我的Ionic应用程序项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Ionic应用程序项目。我想为我的应用添加Android支持。因为我使用离子平台添加Android,但我的系统显示一些错误,我使用的是Windows机器,cmd中显示的错误是

pm_cache\cordova- android\6.0.0\package\bin\create.bat E:\workspace\appstore\demoapp\platforms\android com.ionicframework.demoapp722446 demoapp  - -cli

C:\Users\SYSTEM-03\.cordova\lib\\\
pm_cache\cord- android\6.0.0\package\bin\ template \cordova\lib\AndroidStudio.js:16
(eclipseFiles文件){
^^
语法错误:意外的标识符
在Module._compile(module。 js:439:25)
在Object.Module._extensions..js(module.js:474:10)
在Module.load(module.js:356:32)
at Function.Modul e._load(module.js:312:12)
at Module.require(module.js:364:17)
at require(module.js:380:17)
at Object <匿名> (C:\Users\SYSTEM-03\.cordova\lib\\\
pm_cache\cordova-android\6.0.0\package\bin\templates\cordova\lib\AndroidProject。 js:24:21)
在Module._compile(module.js:456:26)
在Object.Module._extensions..js(module.js:474:10)
at Module.load(module.js:356:32)


解决方案

您需要安装需要的版本和Android studio的java。在java和android studio的环境变量中设置路径。



按照以下步骤



要求



为了安装离子框架,我们应该有以下要求。它支持iOS 6+,Android 4.0+。
Node.js
Apache Cordova
Ionic
Git
Java JDK
Apache Ant
Android Studio
Google Chrome Canary(可选) )



Windows OS
中的步骤从此下载并安装Node.js。 (这里node.js是一个可执行文件)



安装Cordova
使用以下命令安装cordova。 (npm是一个node.js相关的命令)

  C:\ npm install -g cordova 

安装图标

  C: \ npm install -g ion 

安装Git
从此下载并安装Git。安装时选择从Windows命令提示符运行Git选项。当我们要从github(.git文件)安装cordova插件时,将使用Git。



安装JDK,Apache Ant,Android Studio
安装最新的Java从
创建JDK(不仅仅是JRE)为JAVA_HOME创建指向java JDK根文件夹的环境变量。

  C :\ set JAVA_HOME =C:\Program Files\Java\jdk7

添加JDK的bin到PATH环境变量

  C:\ set PATH =%PATH%;C:\Program Files\\ \\ Java\jdk7\bin

从此下载Apache Ant。
将其提取到 C:\目录
将Ant的bin添加到PATH环境变量中



C:\设置PATH =%PATH%;C:\apache-ant-1.9.2\bin

从此下载Android Studio。
安装Android Studio
从Android Studio配置选项
打开Android SDK Manager b选择以下软件包。
Android SDK工具
Android SDK平台工具
Android SDK Build-tool for Revision 20& 19
Android 6.0(API 23)
Android 4.4W.2(API 20)
Android 4.4.2(API 19)
Android支持库(来自Extras)
单击安装软件包并接受所有软件包的许可。
Cordova需要设置ANDROID_HOME环境变量。

  C:\ set ANDROID_HOME =C:\android \sdk

更新PATH变量以包含工具和平台工具/ / code>文件夹。

  C:\设置PATH =%PATH%;%ANDROID_HOME %\tools 
C:\ set PATH =%PATH%;%ANDROID_HOME%\platform-tools

创建Ionic项目
我们可以在计算机上的某处创建Cordova-Ionic项目。
C:\ ion start [blank / tabs / sidemenu / maps]
C:\ cd



Ionic命令行功能:
a。开始:
c:>离子启动myproj空白
在您运行此命令的目录中创建离子项目。



b。服务:
c:\myproj> ion serve
启动本地开发服务器以运行项目。



c。平台:
c:\myproj>离子平台添加android
配置cordova为所需的平台android或ios。



d。 build:
c:\myproj> ion build android
Build为我们指定的平台执行本地构建。这将在c:\myproj\platforms\android\ant-build位置创建CordovaApp-debug.apk文件。



e。 emulate:
c:\myproj>离子模拟android
以指定平台开始应用



f。运行:
c:\myproj>离子运行android
在实际的移动设备上部署和运行应用程序



g。安装IOS模拟器测试ios构建在Windows机器
c:\ npm install -g ios-sim


I have created an Ionic app project. I want to add Android support to my app. For that I used "ionic platform add Android. But my system shows some errors. I am using a windows machine. The errors showing in cmd is

    Adding android project...

Running command: cmd "/s /c "C:\Users\SYSTEM-03\.cordova\lib\npm_cache\cordova-android\6.0.0\package\bin\create.bat E:\workspace\appstore\demoapp\platforms\android com.ionicframework.demoapp722446 demoapp --cli""

C:\Users\SYSTEM-03\.cordova\lib\npm_cache\cordova-android\6.0.0\package\bin\templates\cordova\lib\AndroidStudio.js:16
    for(file of eclipseFiles) {
             ^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Users\SYSTEM-03\.cordova\lib\npm_cache\cordova-android\6.0.0\package\bin\templates\cordova\lib\AndroidProject.js:24:21)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

解决方案

You need to install java with required version and Android studio. Set the path in the environment variables for both java and android studio.

Follow these steps

Requirements

In order to install ionic framework, we should have the following requirements. It supports iOS 6+, Android 4.0+. Node.js Apache Cordova Ionic Git Java JDK Apache Ant Android Studio Google Chrome Canary (Optional)

Steps in Windows OS Download and install Node.js from this. (Here node.js is an executable file)

Install Cordova Use the below command to install cordova. (npm is a node.js related command)

C:\ npm install -g cordova

Install iconic

C:\ npm install -g ionic

Install Git Download and install Git from this. Choose "Run Git from the Windows Command Prompt" option while installing. Git will be used when we want to install cordova plugins from github (.git files).

Install JDK, Apache Ant, Android Studio Install most recent Java JDK (not just JRE) from this Create an environmental variable for JAVA_HOME pointing to java JDK root folder.

C:\ set JAVA_HOME="C:\Program Files\Java\jdk7"

Add JDK’s bin to the PATH environmental variable

C:\ set PATH=%PATH%;"C:\Program Files\Java\jdk7\bin"

Download Apache Ant from this. Extract it to the C:\ directory Add Ant’s bin to the PATH environmental variable

C:\ set PATH=%PATH%;"C:\apache-ant-1.9.2\bin"

Download Android Studio from this. Install Android Studio Open "Android SDK Manager" from Android Studio "Configure" option Select following packages. Android SDK Tools Android SDK Platform-tools Android SDK Build-tools for Revision 20 & 19 Android 6.0 (API 23) Android 4.4W.2 (API 20) Android 4.4.2 (API 19) Android Support Library (From Extras) Click on "Install Packages" and accept license for all packages. Cordova requires the ANDROID_HOME environmental variable to set.

C:\ set ANDROID_HOME="C:\android\sdk"

Update PATH variable to include tools/ and platform-tools/ folder in that folder.

C:\ set PATH=%PATH%;%ANDROID_HOME%\tools
        C:\ set PATH=%PATH%;%ANDROID_HOME%\platform-tools

Create Ionic project We can create Cordova-Ionic project somewhere on the computer. C:\ ionic start [blank/tabs/sidemenu/maps] C:\ cd

Ionic command line features: a. start: c:> ionic start myproj blank Creates ionic project in the in which directory you have run this command.

b. serve: c:\myproj> ionic serve Starts local development server to run the project.

c. platform: c:\myproj> ionic platform add android Configure cordova for desired platform android or ios.

d. build: c:\myproj> ionic build android Build executes a local build for the platform which we specify. This creates CordovaApp-debug.apk file in c:\myproj\platforms\android\ant-build location.

e. emulate: c:\myproj> ionic emulate android Starts the app in specified platform

f. run: c:\myproj> ionic run android Deploys and runs the app on the actual mobile device

g. Install IOS emulator test ios build in windows machine c:\ npm install -g ios-sim

这篇关于如何添加Android支持我的Ionic应用程序项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆