eclipse “修复项目属性”命令究竟有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6056511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does the command "Fix Project Properties" exactly do?
提问by Axel M. Garcia
What does the "Project->Android Tools->Fix Project Properties" Eclipse command exaclty do?
"Project->Android Tools->Fix Project Properties" Eclipse 命令具体有什么作用?
I have read many times to use it, mostly in answers related with Android R generation problems in Eclipse, but for me it is like magic, I press on it and I suppose it Fixs some Project Properties, but nothing happens... no visual feedback, no info on which project properties has been fixed... anyone can give a bit of insight on what does it exactly do?
我已经阅读了很多次来使用它,主要是在与 Eclipse 中的 Android R 生成问题相关的答案中,但对我来说它就像魔术一样,我按下它,我想它修复了一些项目属性,但没有任何反应......没有视觉效果反馈,没有关于哪些项目属性已修复的信息......任何人都可以对它究竟做了什么提供一些见解?
Thx
谢谢
回答by Ludevik
By looking into ADT source code, specifically into FixProjectActionand reading source and comments we can see that it calls:
通过查看 ADT 源代码,特别是FixProjectAction并阅读源代码和注释,我们可以看到它调用:
ProjectHelper.fixProject(project);
ProjectHelper.fixProjectNatureOrder(project);
AndroidNature.configureResourceManagerBuilder(project);
AndroidNature.configurePreBuilder(project);
AndroidNature.configureApkBuilder(project);
ProjectHelper.fixProject(project)does:
ProjectHelper.fixProject(project)执行以下操作:
- creates Java project
- fixes classpath entries to ensure that:
- the project does not reference any old android.zip/android.jar archive
- the project does not use its output folder as a sourc folder
- the project does not reference a desktop JRE
- the project references the AndroidClasspathContainer.
- 创建 Java 项目
- 修复类路径条目以确保:
- 该项目没有引用任何旧的 android.zip/android.jar 存档
- 该项目不将其输出文件夹用作源文件夹
- 该项目未引用桌面 JRE
- 该项目引用了 AndroidClasspathContainer。
ProjectHelper.fixProjectNatureOrder(project)reorders project natures, so that Android project nature is first.
ProjectHelper.fixProjectNatureOrder(project) 对项目性质进行重新排序,因此 Android 项目性质是第一位的。
AndroidNature.configureResourceManagerBuilder(project)adds the ResourceManagerBuilder, if its not already there. It'll insert itself as the first builder.
AndroidNature.configureResourceManagerBuilder(project)添加 ResourceManagerBuilder,如果它还没有的话。它将自己作为第一个构建器插入。
AndroidNature.configurePreBuilder(project)adds the PreCompilerBuilder if its not already there. It'll check for presence of the ResourceManager and insert itself right after.
AndroidNature.configurePreBuilder(project)添加 PreCompilerBuilder 如果它不存在的话。它将检查 ResourceManager 的存在并在之后立即插入。
AndroidNature.configureApkBuilder(project)adds the .apk builder at the end if it's not already there.
AndroidNature.configureApkBuilder(project)会在最后添加 .apk 构建器(如果它还没有)。
Last three calls ensure that you have correct builder for your project. When you look at your Builders section in eclipse project properties you will see:
最后三个调用确保您的项目具有正确的构建器。当您查看 eclipse 项目属性中的 Builders 部分时,您将看到:
- Android Resource Manager first
- Android Pre Compiler after Resource Manager
- Android Package Builder last
- Android 资源管理器优先
- 资源管理器后的Android预编译器
- Android Package Builder 最后
回答by AndroidGuy
Another result of running "Fix Project Properties" on a project is that any other projects in the same workspace that reference the project as an Android library may have jars which get linked in under "Android Dependencies" on the project build path.
在项目上运行“修复项目属性”的另一个结果是,同一工作区中将项目作为 Android 库引用的任何其他项目都可能具有在项目构建路径上的“Android 依赖项”下链接的 jar。
This can result in multiple references to the same jar file or missing jar file references.
这可能导致对同一 jar 文件的多次引用或缺少 jar 文件引用。
The fix is to remove those links from the related projects, remove the "Android Dependency" and re-run "Fix Project Properties".
修复方法是从相关项目中删除这些链接,删除“Android 依赖项”并重新运行“修复项目属性”。