如何手动安装cordova(3.0) [英] How to install cordova(3.0) manually

查看:88
本文介绍了如何手动安装cordova(3.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了apache cordova 3.3.0。它有cordova-android子文件夹,我解压缩它。我如何将这个复制到我的Android项目?我找不到jar文件和xml。
以及如何手动添加插件到此项目?



我不想要命令行方法。因为我的公司不允许它下载。



任何有关这方面的帮助将不胜感激。

解决方案

我不确定使用cordova没有cli会很容易,也许你应该尝试phonegap build而不是下载在您的计算机上。



无论如何,让我们来看看我们可以做什么...



你不说你要定位哪个平台,所以我试着解释一下我知道:android。



首先,先决条件






  • java jdk(并设置JAVA_HOME env var)

  • apache ant

  • Android sdk

  • 从android sdk管理器安装最新的平台工具(as cordova 3.3.0,is is API 19 )




p>在 cordova文档中的平台指南中查看完整列表



然后安装cordova



cordova来源zip从下载页面,并解压到您的硬盘驱动器(可以是临时文件夹)。



在解压缩的文件夹中,您将为每个平台找到一个zip,因此对于Android我们将使用cordova-android.zip。



将此文件夹解压到用户主文件夹中的某处,并修改您的路径以包括 cordova-android\bin文件夹



现在您可以访问cordova工具,您可以从命令行运行(很像CLI)(如果您使用的是windows,则使用.bat文件):




  • check_reqs :运行此操作以检查计算机上是否存在每个依赖项

  • android_sdk_version :运行此检查android api安装(应返回19为cordova 3.3正常工作)

  • update :使用此选项将现有项目更新为新版本的cordova(因此我暂时不需要此项目)

  • 创建:使用此图标创建一个新的cordova项目。检查 cordova在cli中的创建的参数除了运行 create 而不是 cordova create



现在您可以创建一个项目



new cordova项目运行下面的命令(记住,如果你在windows上,create.bat):

  create myapp com.mycompany .myapp MyApp 

您刚刚在myapp文件夹中创建了MyApp应用程序。



在eclipse中导入项目



在eclipse中,进入新的项目向导并从现有代码中选择



您应该会看到两个项目:




  • MyApp:您的应用程序

  • MyApp-CordovaLib:cordova 3.3中,cordova核心不是在一个jar,而是在这个单独的项目。



现在您可以使用eclipse运行/调试项目或构建版本apk。



自定义项目


  • 在assets / www文件夹中自定义您的html5应用程序

  • 更改文件中的android特定设置AndroidManifest.xml(例如自动化)

  • 在文件res / xml / config.xml中更改cordova设置(类似于插件的功能)



添加插件



使用cordova 3您需要为每个API安装插件,所以如果没有插件,您将无法



通常使用cordova CLI或plugman CLI安装插件(也需要使用npm安装),但是,



因为我的时间不多了,我会在以后讨论这个主题,如果你需要它,或者其他人问


I downloaded apache cordova 3.3.0. It has cordova-android sub folder , i unzipped it . how do i copy this to my android project? I cant find the jar file and the xml . and also how to add plugin to this project manually?

I dont want command line approach. Because my company wont allow it to download .

Any help regarding this would be appreciated.

解决方案

I'm not sure using cordova without the cli will be very easy and maybe you should try phonegap build instead (nothing at all to download on your computer).

Anyway, let's see what we can do...

You do not say which platform you are targeting, so I'll try to explain for what I know : android.

First, the prerequisites

You have to have on your computer and available in the path:

  • java jdk (and set the JAVA_HOME env var)
  • apache ant
  • android sdk
  • install the latest platform tools from the android sdk manager (as of cordova 3.3.0, is is API 19)
  • eclipse with the adt plugin installed (or the eclipse included in the android sdk install)

Check full list in the platform guide in the cordova docs.

Then, install cordova

Then you download the cordova source zip from the download page and extract it somewhere in your hard drive (can be temp folder).

In the extracted folder, you will find one zip for each platform, so for android we will use cordova-android.zip.

Extract this folder somewhere in your user home folder and modify your path to include the cordova-android\bin folder.

Now you have access to cordova tools that you can run from command line (much like with the CLI) (if you're using windows, then use the .bat files):

  • check_reqs : run this to check that every dependencies are found on your computer
  • android_sdk_version : run this to check the android api installed (should return 19 for cordova 3.3 to work correctly)
  • update : use this to update an existing project to the new version of cordova (so I guess you won't need this one for the moment)
  • create : use this one to create a new cordova project. Check the arguments of cordova create in the cli documentation, create works the same, except you run create instead of cordova create.

Now you can create a project

to create a new cordova project run the following command (remember, create.bat if you're on windows) :

create myapp com.mycompany.myapp MyApp

You've just created the MyApp application in the myapp folder.

Import the project in eclipse

In eclipse, go in the new project wizard and select "Android project from existing code" and set the root directory at the root of the previously created project.

You should see two projects :

  • MyApp : your application
  • MyApp-CordovaLib : in cordova 3.3, the cordova core is no more in a jar but in this separate project.

Now you can use eclipse to run/debug the project or build release apk.

Customise your project

  • customise your html5 appp in the assets/www folder
  • change android specific settings in the file AndroidManifest.xml (like autorisations for example)
  • change cordova settings in the file res/xml/config.xml (like features for plugins)

Add plugins

With cordova 3 you will need to install plugins for every API, so without plugins you will not be able to call any native API and be limited to HTML5 API.

Usually you install plugins using the cordova CLI, or plugman CLI (also need to be installed with npm), but here you will have to do everything manually.

As I'm running out of time, I'll cover this subject later, if you need it or if other people ask for it.

这篇关于如何手动安装cordova(3.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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