使用Eclipse和Phonegap / Cordova进行开发3

时间:2023-02-05 09:06:38

It seem the documentation is a bit thin and I assure you I have tried to find this online, but I really don't get how the development process is supposed to work with phonegap and eclipse.

看起来文档有点薄,我向你保证我试图在网上找到这个,但我真的不知道开发过程应该如何与phonegap和eclipse一起工作。

I followed one of the many tutorials and created the Hello World example using the the cordova command line. I then added the android platform and ran the build. After that, I added the andoridy bit as a project in eclipse with respect to existing source as instructed using the subdirectory platforms/android directory. This allowed me to set up the emulator and all worked very well.

我按照许多教程之一,使用cordova命令行创建了Hello World示例。然后我添加了android平台并运行了构建。之后,我根据使用子目录platforms / android目录指示的现有源添加了ororidy位作为eclipse中的项目。这使我能够设置模拟器,并且一切运行良好。

The problem I now have is with the development process.

我现在遇到的问题是开发过程。

I understand that I have to edit the top level files, not the ones presented in the assets directory of the project in eclipse as these are created using the "build" command. These top level files don't exist in the project I've created in eclipse as they are above the root of the project.

我知道我必须编辑*文件,而不是eclipse中项目资产目录中显示的文件,因为它们是使用“build”命令创建的。我在eclipse中创建的项目中不存在这些*文件,因为它们位于项目的根目录之上。

So, my question is ... can I use eclipse to develop this project in a sensible way?

所以,我的问题是......我可以使用eclipse以合理的方式开发这个项目吗?

What I'm doing at the moment is editing the android www files and then to pump it up to the cloud build, I'm copying them back up the tree. This seems insane.

我现在正在做的是编辑android www文件,然后将其提升到云构建,我将它们复制回树上。这看起来很疯狂。

Is there a way of having the real files available in eclipse so I can develop them and then build and deploy to an emulator easily?

有没有办法在eclipse中提供真实文件,以便我可以开发它们然后轻松地构建和部署到模拟器?

PS is it my imagination or does cordova build take ages!

PS是我的想象力还是Cordova构建需要多年!

Solution

I added a folder within the Android project which is a link to the location of the www in the root. This is under advanced options of creating a folder.

我在Android项目中添加了一个文件夹,它是指向根目录中www的位置的链接。这是在创建文件夹的高级选项下。

3 个解决方案

#1


15  

To do this, you must use two different eclipse projects. One containing the myProject/www folder for developing (let's call it 'top-level project') and one for your specific platform-project (e.g. android, as you already did).

为此,您必须使用两个不同的eclipse项目。一个包含用于开发的myProject / www文件夹(让我们称之为'*项目')和一个用于特定平台项目的文件夹(例如android,就像你已经做过的那样)。

In your top level project, you write your code and, if you feel like, you can even debug up to a certain degree (functions which do not require cordova). Then save and type cordova prepare in your CLI. You can then switch to your android project, hit refresh (F5) and run the emulator / device and look for bugs, and make Android-Manifest changes. If you want to change code, switch again to your top-level project and do the same over again.

在您的*项目中,您编写代码,如果您愿意,您甚至可以调试到一定程度(不需要cordova的功能)。然后在CLI中保存并输入cordova prepare。然后,您可以切换到您的Android项目,点击刷新(F5)并运行模拟器/设备并查找错误,并进行Android-Manifest更改。如果要更改代码,请再次切换到*项目并再次执行相同操作。

This seems a bit unhandy, right. Nevertheless, think about cordova not beeing only for developing on android, but also on ios, windows phone, blackberry, ... To access all these platforms, you have to switch to multiple ide's anyway. It makes it a lot easier then, to have the top-level code in a independent project.

这似乎有点不方便,对。然而,想想cordova不仅仅是为了在Android上开发,而且还在ios,windows phone,blackberry上......要访问所有这些平台,你必须切换到多个ide。这使得在独立项目中使用*代码变得容易得多。

Some sidenodes:

一些侧节点:

  1. After doing this process a few times, you will loose not more than 2 or 3 seconds to cordova prepare and switch projects. Which is ok, I think.

    完成这个过程几次后,你将失去不超过2或3秒的时间来完成cordova准备和切换项目。我认为哪个好。

  2. I myself don't just use different eclipse projects, I even use different eclipse installations. This seemed better arranged for me, as it protects me from confusing top and low level files.

    我自己不只是使用不同的eclipse项目,我甚至使用不同的eclipse安装。这似乎更适合我,因为它保护我免受混淆*和低级文件。

  3. Even if you develop only for android, you should use two different projects, as 'cordova prepare' (or any cli command containing prepare, as build, emulate and run) would overwrite/delete your files.

    即使你只为android开发,你应该使用两个不同的项目,因为'cordova prepare'(或任何包含prepare,如build,emulate和run的cli命令)会覆盖/删除你的文件。

  4. On my installation, building with CLI takes the same amount of time as it does in eclipse. Which makes sense, as I am using the same sdk for both. However, in the process written above, there is no need to use the cli-build command.

    在我的安装中,使用CLI构建所需的时间与在eclipse中相同。这是有道理的,因为我使用相同的sdk。但是,在上面编写的过程中,不需要使用cli-build命令。

  5. If you use just the android platform and don't get easily confused with same-named files in one project, you might link the myApp/www folder in your Android project. In this case, you will only have one project (Credit for this answer goes to stevemarvell himself, im just adding this here for completeness)

    如果您只使用Android平台,并且不容易与一个项目中的同名文件混淆,您可以链接Android项目中的myApp / www文件夹。在这种情况下,你将只有一个项目(这个答案的信用额去了stevemarvell本人,我只是为了完整性而添加这个)

#2


0  

in addition to the solution above, i created an 'external tools' configuration that runs the phonegap utility with 'local build android' options and a environment PATH variable set to '/opt/local/bin:/usr/bin:/bin' for my Mac. from there, i installed the Eclipse CDT tools and used its 'Launch Group' feature to run the external tool from the top-level project before calling a debug on the platform-specific project.

除了上面的解决方案,我创建了一个“外部工具”配置,运行带有'local build android'选项的phonegap实用程序和一个设置为'/ opt / local / bin:/ usr / bin:/ bin'的环境PATH变量对于我的Mac。从那里,我安装了Eclipse CDT工具,并使用其“启动组”功能从*项目运行外部工具,然后在特定于平台的项目上调用调试。

seems to work fairly well. unfortunately they top-level project doesn't 'remember' the Launch Group execution, so i have to select it from the Debug drop-down each time. i converted the top-level project to a JavaScript as a test, but it didn't seem to help and the 'Run/Debug Settings' in Project Properties are all greyed out.

似乎运作得相当好。不幸的是,他们*项目没有“记住”启动组执行,所以我必须每次从Debug下拉列表中选择它。我将*项目转换为JavaScript作为测试,但它似乎没有帮助,项目属性中的“运行/调试设置”都显示为灰色。

#3


0  

See my answer here: Multiple Html files in PhoneGap Android project

在这里查看我的答案:PhoneGap Android项目中的多个Html文件

Why I moved to Netbeans with Phonegap 3.0 CLI. Suited my workflow better.

为什么我使用Phonegap 3.0 CLI转移到Netbeans。更适合我的工作流程。

#1


15  

To do this, you must use two different eclipse projects. One containing the myProject/www folder for developing (let's call it 'top-level project') and one for your specific platform-project (e.g. android, as you already did).

为此,您必须使用两个不同的eclipse项目。一个包含用于开发的myProject / www文件夹(让我们称之为'*项目')和一个用于特定平台项目的文件夹(例如android,就像你已经做过的那样)。

In your top level project, you write your code and, if you feel like, you can even debug up to a certain degree (functions which do not require cordova). Then save and type cordova prepare in your CLI. You can then switch to your android project, hit refresh (F5) and run the emulator / device and look for bugs, and make Android-Manifest changes. If you want to change code, switch again to your top-level project and do the same over again.

在您的*项目中,您编写代码,如果您愿意,您甚至可以调试到一定程度(不需要cordova的功能)。然后在CLI中保存并输入cordova prepare。然后,您可以切换到您的Android项目,点击刷新(F5)并运行模拟器/设备并查找错误,并进行Android-Manifest更改。如果要更改代码,请再次切换到*项目并再次执行相同操作。

This seems a bit unhandy, right. Nevertheless, think about cordova not beeing only for developing on android, but also on ios, windows phone, blackberry, ... To access all these platforms, you have to switch to multiple ide's anyway. It makes it a lot easier then, to have the top-level code in a independent project.

这似乎有点不方便,对。然而,想想cordova不仅仅是为了在Android上开发,而且还在ios,windows phone,blackberry上......要访问所有这些平台,你必须切换到多个ide。这使得在独立项目中使用*代码变得容易得多。

Some sidenodes:

一些侧节点:

  1. After doing this process a few times, you will loose not more than 2 or 3 seconds to cordova prepare and switch projects. Which is ok, I think.

    完成这个过程几次后,你将失去不超过2或3秒的时间来完成cordova准备和切换项目。我认为哪个好。

  2. I myself don't just use different eclipse projects, I even use different eclipse installations. This seemed better arranged for me, as it protects me from confusing top and low level files.

    我自己不只是使用不同的eclipse项目,我甚至使用不同的eclipse安装。这似乎更适合我,因为它保护我免受混淆*和低级文件。

  3. Even if you develop only for android, you should use two different projects, as 'cordova prepare' (or any cli command containing prepare, as build, emulate and run) would overwrite/delete your files.

    即使你只为android开发,你应该使用两个不同的项目,因为'cordova prepare'(或任何包含prepare,如build,emulate和run的cli命令)会覆盖/删除你的文件。

  4. On my installation, building with CLI takes the same amount of time as it does in eclipse. Which makes sense, as I am using the same sdk for both. However, in the process written above, there is no need to use the cli-build command.

    在我的安装中,使用CLI构建所需的时间与在eclipse中相同。这是有道理的,因为我使用相同的sdk。但是,在上面编写的过程中,不需要使用cli-build命令。

  5. If you use just the android platform and don't get easily confused with same-named files in one project, you might link the myApp/www folder in your Android project. In this case, you will only have one project (Credit for this answer goes to stevemarvell himself, im just adding this here for completeness)

    如果您只使用Android平台,并且不容易与一个项目中的同名文件混淆,您可以链接Android项目中的myApp / www文件夹。在这种情况下,你将只有一个项目(这个答案的信用额去了stevemarvell本人,我只是为了完整性而添加这个)

#2


0  

in addition to the solution above, i created an 'external tools' configuration that runs the phonegap utility with 'local build android' options and a environment PATH variable set to '/opt/local/bin:/usr/bin:/bin' for my Mac. from there, i installed the Eclipse CDT tools and used its 'Launch Group' feature to run the external tool from the top-level project before calling a debug on the platform-specific project.

除了上面的解决方案,我创建了一个“外部工具”配置,运行带有'local build android'选项的phonegap实用程序和一个设置为'/ opt / local / bin:/ usr / bin:/ bin'的环境PATH变量对于我的Mac。从那里,我安装了Eclipse CDT工具,并使用其“启动组”功能从*项目运行外部工具,然后在特定于平台的项目上调用调试。

seems to work fairly well. unfortunately they top-level project doesn't 'remember' the Launch Group execution, so i have to select it from the Debug drop-down each time. i converted the top-level project to a JavaScript as a test, but it didn't seem to help and the 'Run/Debug Settings' in Project Properties are all greyed out.

似乎运作得相当好。不幸的是,他们*项目没有“记住”启动组执行,所以我必须每次从Debug下拉列表中选择它。我将*项目转换为JavaScript作为测试,但它似乎没有帮助,项目属性中的“运行/调试设置”都显示为灰色。

#3


0  

See my answer here: Multiple Html files in PhoneGap Android project

在这里查看我的答案:PhoneGap Android项目中的多个Html文件

Why I moved to Netbeans with Phonegap 3.0 CLI. Suited my workflow better.

为什么我使用Phonegap 3.0 CLI转移到Netbeans。更适合我的工作流程。