将现有的Android项目导入Eclipse [英] Importing Existing Android Project into Eclipse

查看:146
本文介绍了将现有的Android项目导入Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将现有的Android项目导入Eclipse时,project.properties正在更新不正确。此文件存在于源代码控制中:

 #此文件由Android Tools自动生成。 
#不要修改此文件 - 您的更改将被删除!

#必须在版本控制系统中检查此文件。

#要自定义Ant构建系统使用的属性,使用
#ant.properties,并重写值以使脚本适应
#项目结构。

#项目目标。
target = Google Inc.:Google API:14

导入项目后(和做没有其他)文件看起来像这样:

 #这个文件是由Android Tools自动生成的。 
#不要修改此文件 - 您的更改将被删除!

#必须在版本控制系统中检查此文件。

#要自定义Ant构建系统使用的属性,使用
#ant.properties,并重写值以使脚本适应
#项目结构。

#项目目标。
target = android-8

清单有以下项目:

 < uses-sdk 
android:minSdkVersion =8
android:targetSdkVersion =14/>

这意味着每次有人导入项目时,我们都必须重置项目中的构建目标 - >属性 - > android菜单。我安装了最新的ADT工具,所有SDK都已经下载并可用。



我尝试过的东西:


  1. 在导入之前删除整个项目,包括磁盘上的内容,克隆和删除project.properties文件。

  2. 删除整个项目,包括磁盘上的内容,克隆和删除.settings文件夹,然后再导入。相同的结果。

  3. 删除整个项目,包括磁盘上的内容,克隆和导入只是为了咧嘴笑。相同的结果。

  4. 通过.project文件进行筛选。没有任何兴趣。

  5. 双重检查ant.properties,build.xml和每个其他纯文本可读文件的线索。没有任何兴趣。

  6. 搜索问题,并重新检查Eclipse和ADT错误网站的已知问题。 Nada。

  7. 在文件系统上验证该文件实际上在克隆后具有正确的设置,导入是罪魁祸首。

  8. 删除整个项目,包括磁盘上的内容,克隆,手动将project.properties文件编辑为android-14,导入。这导致了project.properties文件不变,但是由于我使用Google API进行映射是不能接受的。

我刚刚验证导入后可以修复项目。从Eclipse中删除项目,但将内容留在磁盘上。导入项目错误地再次编辑project.properties。导入过程无法识别project.properties中的Google API条目。



这是我将文件系统中的项目从Eclipse中获取:





想法?

解决方案

现在使用常规 - >现有项目进入工作区而不是Android - >现有Android代码进入Workspace以避免project.properties文件被自动生成不正确。



你是正确的,如果你的android项目没有.classpath,android包结构失去了但是如果你的Android项目已经是一个Eclipse项目,那么它应该导入就好了。



这是一个日常的bug。 http://code.google.com/p/android/issues/detail ?id = 40161



此摘录解释了问题。



如果要导入Eclipse项目(它有一个.classpath),只需使用通用的Eclipse项目导入机制;那就是(Import> General> Existing Projects进入工作空间)我们添加了Import> Android>现有的Android代码到Workspace,因为很多人都有非Eclipse项目导入,这不是很好的支持;你必须创建新,然后使用复选框选择现有的代码等,项目的位置和现有来源的位置是不明确的,我们使现有的Android代码导入选项也可以用于Eclipse项目,这样可以是一个明显的方式提取源代码,但这是新的代码,而不是一般的Eclipse内置导入代码,这就是为什么它不会以它曾经使用的方式拾取项目名称(处理从源代码添加新项目的相关代码确实采取与现在的代码相同的古怪方式,从清单中挑选一个项目名称),但是,使它从.project文件中查找项目名称作为更好的默认值(如果存在)应该是可行的,所以我也尝试添加。


project.properties is being updated incorrectly when importing an Existing Android project into Eclipse. This file exists in source control:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=Google Inc.:Google APIs:14

After importing the project (and doing NOTHING else) the file looks like this:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8

The manifest has the following items:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="14"/>

This means that every time someone imports the project we're having to reset the build target in the project->properties->android menu. I have the latest ADT tools installed and all SDKs are downloaded and available.

Things I've tried:

  1. Deleting the entire project including contents on disk, cloning and deleting the project.properties file before importing. Same result.
  2. Deleting the entire project including contents on disk, cloning and deleting the .settings folder before importing. Same result.
  3. Deleting the entire project including contents on disk, cloning and importing just for grins. Same result.
  4. Scoured through the .project file. Nothing of interest.
  5. Double checked ant.properties, build.xml and every other plain text readable file for clues. Nothing of interest.
  6. Googled the problem and double checked the Eclipse and ADT bug sites for known issues. Nada.
  7. Verified on the file system that the file does, in fact, have the correct setting after cloning and that the import is the culprit.
  8. Deleting the entire project including contents on disk, cloning, MANUALLY editing the project.properties file to android-14, importing. This resulted in an unchanged project.properties file but since I'm using the Google APIs for mapping this is unacceptable.

I just verified that I can "fix" the project after it's imported. Delete the project from Eclipse but leaving the contents on disk. Importing the project incorrectly edits project.properties again. The import process does not recognize the Google APIs entries in project.properties.

This is how I'm getting the project from the file system into Eclipse:

Thoughts?

解决方案

For now use General -> Existing Projects into Workspace instead of the Android -> Existing Android Code into Workspace to avoid the project.properties file being auto generated improperly.

You are correct, if your android project does not have a .classpath, the android package structure is lost. But if your android project is already an Eclipse project it should import just fine.

This is a bug in eclipse. http://code.google.com/p/android/issues/detail?id=40161

This excerpt explains the problem.

"If you are importing an Eclipse project (which has a .classpath), just use the generic Eclipse project import mechanism; that's still there (Import > General > Existing Projects Into Workspace). We added Import > Android > Existing Android Code Into Workspace because a lot of people had non-Eclipse projects to import, which was not well supported; you had to "Create New" and then use a checkbox to select "existing code" etc, and the location of the project and the location of the existing sources was ambiguous. We made the Existing Android Code import option also work for Eclipse projects, such that it would be a single obvious way to pull in source code. But this is new code, not the general Eclipse builtin import code, which is why it doesn't pick up the project name in the way it used to. (The related code which handled adding new project from source did act in the same quirky way the code does now, picking a project name from the manifest). However, making it look up the project name from the .project file as a better default, if present, should be doable so I'll try to add that as well."

这篇关于将现有的Android项目导入Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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