无法从 Android/Eclipse 上的示例或下载导入或创建新项目
基本上,我需要帮助导入下载的源代码或从示例源程序创建项目。如果有人可以指出我或发布步骤,我正在寻找这两个步骤的说明。
我对 Android/Eclipse 很陌生。我已经安装了环境,并成功编写了一个非常小的应用程序,可以在模拟器和我真正的 Droid X 上运行。但是,我无法将任何 Android 示例毫无错误地放入项目中。我尝试过导入、从现有源创建等等,但到处都是错误。
然而,我已经成功创建了一个新的空项目,然后将组件一次一个地放入项目中,为每个文件键入或粘贴代码。我将鼠标悬停在上面并根据需要导入 Android 和其他组件。例如,WiktionarySimple 运行时只进行了一些更改和几个我没有处理的警告。 (我必须在下面的语句中添加“formatted=”false”...)
<string name="template_user_agent" formatted="false">"%s/%s (Linux; Android)"</string>
<string name="template_wotd_title" formatted="false">"Wiktionary:Word of the day/%s %s"</string>
但是必须有一种更简单的导入方法!我已经做了直觉,并按照我找到的说明进行操作,但无济于事。谁能给我一个完整的列表,说明如何从现有源或从网上下载的源导入或创建项目?
Basically, I need help importing downloaded source or creating a project from sample source programs. I'm looking for step by step instructions for both if anyone can point me there or post the steps.
I'm very new to Android/Eclipse. I have the environments installed and have successfully written a very minor app that works on the emulator and my real Droid X. I cannot, however, get any of the Android samples into a project without errors. I've tried importing, creating from existing source, and etcetera and it's all a mess with errors everywhere.
I have, however, successfully created a new empty project, then brought the components into the project one at a time typing or pasting in code for every file. I'd hover over and import Android and other components as needed. The WiktionarySimple, for example, ran with only a couple of changes and several warnings that I left alone. (I had to add 'formatted="false" in the statements below...)
<string name="template_user_agent" formatted="false">"%s/%s (Linux; Android)"</string>
<string name="template_wotd_title" formatted="false">"Wiktionary:Word of the day/%s %s"</string>
But there has to be an easier way to import! I've done the intuitive and I've followed instructions that I've found, but to no avail. Can anyone give me a complete list as to how to import or create a project from existing source or from source I've downloaded from the web?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
步骤#1:启动一个新的 Android 项目
步骤#2:在 Android 项目向导的第一页中,选择“从现有源创建项目”单选按钮,然后单击“浏览”按钮并找到包含该项目的目录
步骤#3 :调整设置以适应,然后按完成
步骤#4:如果需要(不确定是否不再需要),右键单击项目名称,然后选择“构建路径”>“构建路径”。从上下文菜单中配置构建路径,并确保选中清单中的 Android 条目
Step #1: Start a new Android project
Step #2: In the first page of the Android project wizard, choose the "Create project from existing source" radio button, then click the Browse button and find the directory containing the project
Step #3: Tweak settings to suit, then press Finish
Step #4: If needed (not sure if it is anymore), right-click over the project name, and choose Build Path > Configure Build Path from the context menu, and make sure the Android entry in the checklist is checked
您很可能没有错误地导入这些项目,而只是遇到了导入项目时出现的常见问题。
例如,涉及添加
formatted="false"
的问题非常常见,并且由于 aapt 的严格性发生了变化,这在 这个问题。示例项目很可能是在更改之前创建的,并且此后就没有更新过。涉及
formatted="false"
的错误还可能导致更多错误,因为该错误之后的任何 xml 通常都不会被解析,因此在其之后声明的任何资源都是未知的。因此,错误找不到与给定名称匹配的资源(在'hint'处,值为'@string/search_hint')
和其他类似错误通常是由于formatted="false"< /代码> 错误。我建议使用
formatted="false"
修复所有 % 符号错误,然后让它重建并查看还剩下多少错误。至于
String types not allowed (at 'layout_width' with value 'match_parent')
在 stackoverflow 上的快速搜索表明,这是因为FILL_PARENT
被替换为MATCH_PARENT在 Android 2.2 中。因此,您需要将项目的 sdk 设置为 Android 2.2 或更高版本。这也是该问题的链接。
Its quite possible that you are not importing these projects incorrectly and that you are simply running into common problems that occur when importing projects.
For instance your problem involving adding
formatted="false"
is quite common and due to a change in the strictness of aapt, which is explained in this question. It is likely that the sample project was created before the change and has not been updated since.That error involving the
formatted="false"
can also cause many more errors, since any xml after that error is often not parsed and thus any resources declared after it are not known. So the errorNo resource found that matches the given name (at 'hint' with value '@string/search_hint')
and others like it are often due to theformatted="false"
error. I would suggest fixing all the % sign errors with theformatted="false"
then letting it rebuild and see how many errors are left.As for the
String types not allowed (at 'layout_width' with value 'match_parent')
a quick search on stackoverflow says that its caused becauseFILL_PARENT
was replaced withMATCH_PARENT
in Android 2.2. So you need to set your sdk for the project to be Android 2.2 or higher. Here is the link to that question as well.我在导入维基词典样本时发生了这种情况,我找到了解决方案。
(可能是可选的)
6. 更改 Android Manifest 中的目标和最低 SDK
This happened to me in importing the wiktionary sample and i found the solution.
(probably optional)
6. Change the target and Minimum SDK in the Android Manifest