如何强制eclipse在每个版本的硬件设备上更新apk? [英] How do I force eclipse to update the apk on my hardware device with each build?

查看:139
本文介绍了如何强制eclipse在每个版本的硬件设备上更新apk?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我更改一些代码,保存和运行,它运行程序的最后一个版本,而不是我刚刚保存。我可以让它更新的唯一方法是如果我清理项目,构建项目,然后运行项目。有没有办法避免这种烦恼?

解决方案

我花了一些时间创建两个虚拟项目(一个Android和一个Java),有一个玩,最后想出一个不经常使用但能够解决你的要求的解决方法。



首先,我会解释一下你的问题更多(基于我的理解和我所尝试的),以便其他人能够更清楚地了解这里发生了什么。



根据评论中的对话:


你能告诉我你在下面的设置:project-> properties-> Builder? - Sudar Nimalan



@SudarNimalan:我不知道这是你正在问的,但是有文本说配置这个项目的建设者,在它下面是一个单一选项,Java构建器,被选中(选中)。对于Android项目,应该有这样的Android资源管理器,Android预编译器,Java Builder,Android程序包生成器你可以添加那些尝试吗? - Sudar Nimalan



@SudarNimalan:我欠你道歉;我有这四个组成部分。我的项目分为4个项目 - 核心,核心 - 安卓,核心桌面和核心 - html。这有点奇怪,因为我使用libGDX项目设置UI来设置它,当我回答你的问题时,我正在看核心项目。我的'core-android'项目有四个(按照这个顺序),这是我问题的问题。 - shino




场景:



您有4个项目:




  • core:一个常规的java项目(这里是常见的纯java代码)

  • core-android:一个Android应用程序项目。

  • 核心桌面:与问题无关,因此被忽略。

  • core-html:与问题无关。


核心 - android项目依赖于核心项目,通过将核心添加到核心android的构建路径(属性 - > Java构建路径 - >项目 - >添加...)和导出列表(属性 - > Java构建路径 - >订单和导出)。



问题(不是真的):



更改核心中的一些代码并保存它,运行core-android,eclipse安装最后编译的apk,而不是新的一个更改。



原因:



这是预期的行为,你在core-android中引用核心项目的方式只会创建一个弱链接(或某种) betw een core和core-android,core-andorid的自动构建脚本不知道在核心上做出什么改变。您必须清理项目(只需要干净的core-android项目),以便Eclipse可以删除现有的apk(在bin目录下)并重新生成apk(最新的代码从核心更改)。



请参阅下面的Xav的评论,Android SDK工具应该意识到在项目构建路径下从普通Java项目进行的更改,并且此时不会正常处理此功能。

$请注意,如果核心是Android图书馆项目,那么没有问题,您的核心 - android项目将意识到核心项目(java代码,Android资源等)中的任何更改,如果核心只用于core-android,这也可能是一种解决方法:将Java项目核心转换为Android库项目。



解决方法(Eclipse Link Source):



有另一种方式(不常用)在项目之间添加软链接:


  1. ,你需要从core-android的构建路径中删除核心项目,这也是从导出和订单列表中删除它。

  2. 右键单击core-android,选择Build Path - > Link Source ...将../core/src添加为链接文件夹位置和src-lib1作为文件夹名称,请参阅最终的屏幕画面。

在Package Explorer窗口中的core-android下创建一个符号链接src-lib1指向核心的src foder,在文件系统中,您仍然有两个单独的项目文件夹。现在,如果您更改核心代码并运行core-android,Eclipse将构建并安装最新的apk。不需要清理core-android项目。



链接源窗口:



最终查看包资源管理器:





您应该始终考虑正常的方法作为第一选择,毕竟,手动清理项目与上述不寻常的方法相比并不重要。


If I change some code, save, and Run, it runs the last version of the program, not what I just saved. The only way I can make it update is if I Clean the project, Build the project, and then Run the project. Is there some way to avoid this tedium?

解决方案

I spent some time create two dummy projects (one Android and one Java) and have a play with it, and finally come up with a workaround which is not used very often but able to solve your requirements.

First, I will explain your question a bit more (based on my understanding and what I have tried) so that other people can have a more clear understand about what is happened here.

According to the conversation in comments:

could you tell me what you have in following setting: project->properties->Builder ? – Sudar Nimalan

@SudarNimalan: I am not sure this is what you are asking, but: there's text that says "Configure the builders for this project", and under it is a single option, "Java builder", which is selected (checked). – shino

for android project, there should be, "Android Resource Manager", "Android Pre Compiler", "Java Builder", "Android Package Builder" in this order, chould you add those and try? – Sudar Nimalan

@SudarNimalan: I owe you an apology; I do have those four components. My "project" is split into 4 projects - "core", "core-android", "core-desktop", and "core-html". It's a little weird because I set it up with the libGDX project setup UI, and I was looking at the 'core' project when I answered your question. My 'core-android' project has all four (in that order), and it is the one that has the problem in my question. – shino

Scenario:

You have 4 project:

  • core: a regular java project (common pure java code here)
  • core-android: an Android application project.
  • core-desktop: not related to question so ignored.
  • core-html: not related to question so ignored.

The core-android project has dependency on core project, by adding core to core-android's build path (Properties -> Java Build Path -> Projects -> Add ...) and export list (Properties -> Java Build Path -> Order and Export).

Problem (Not Really):

Change some code in core and save it, run core-android, eclipse install last compiled apk, not the new one with change.

Reason:

The is the expected behavior, the way you used to reference core project in core-android only create a weak link (or something sort of) between core and core-android, the core-andorid's auto-build script doesn't aware any changes made in core. You have to clean the project (only need clean core-android project) so that Eclipse can delete the existing apk (under bin directory) and re-generate the apk (with the latest code changes from core).

See Xav's comments below, Android SDK tools should aware changes from plain Java project under project build path, and it does not behaviour this feature normally at the moment.

Note that if core is an Android Library project, then there is no problem and your core-android project will aware any changes in core project (java code, android resource and etc), if core is only used in core-android, this could also be a workaround: turn Java project core into Android library project.

Workaround (Eclipse Link Source):

There is another way (not commonly used) for adding soft link between projects:

  1. First, you need remove core project from core-android's build path, this will also remove it from Export and Order list.
  2. Right click core-android, choose Build Path -> Link Source ... Add ../core/src as Linked Folder Location and src-lib1 as Folder Name,see screen screen in the end.

This create a symbolic link src-lib1 under core-android in Package Explorer windows point to core's src foder, in the file system, you still have two separate project folder. Now if you change some code in core and run core-android, Eclipse will build and install latest apk. No need to clean core-android project.

Link Source Window:

Final look in Package Explorer:

You should always consider the normal approach as first option, after all, manual clean project is not a big deal compare to the unusual approach I described above.

这篇关于如何强制eclipse在每个版本的硬件设备上更新apk?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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