不能从Android/Eclipse的示例或下载中导入或创建新项目

时间:2023-01-17 17:57:08

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.

我对Android/Eclipse很陌生。我已经安装了环境,并成功地编写了一个非常小的应用程序,可以在模拟器和我的真实Droid x上运行。我尝试过导入,从现有的源创建,等等,所有的都是错误。

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...)

然而,我已经成功地创建了一个新的空项目,然后每次将组件放入项目中,为每个文件输入或粘贴代码。我将在需要的时候切换并导入Android和其他组件。例如,wiktionsimple只运行了几项更改和几个警告,我将其放在一旁。(我必须在下面的语句中添加' formatting ="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>

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


6  

Step #1: Start a new Android project

第一步:启动一个新的Android项目

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

步骤2:在Android项目向导的第一页,选择“从现有源创建项目”单选按钮,然后单击Browse按钮,找到包含项目的目录

Step #3: Tweak settings to suit, then press Finish

步骤#3:调整设置以适应,然后按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

步骤#4:如果需要(不确定是否还需要),右键单击项目名称,从上下文菜单中选择Build Path >配置构建路径,并确保检查清单中的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.

例如,您涉及添加格式化=“false”的问题非常常见,这是由于aapt的严格性发生了变化,这个问题在本问题中得到了解释。很可能示例项目是在更改之前创建的,之后没有更新。

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 error No resource found that matches the given name (at 'hint' with value '@string/search_hint') and others like it are often due to the formatted="false" error. I would suggest fixing all the % sign errors with the formatted="false" then letting it rebuild and see how many errors are left.

涉及到formatting ="false"的错误也会导致更多的错误,因为在这个错误之后的任何xml通常都不会被解析,因此在这个错误之后声明的任何资源都是未知的。因此,没有找到匹配给定名称的错误(在'hint'与值'@string/search_hint')和其他类似的错误通常是由于格式化="false"错误造成的。我建议用format ="false"修改所有的%符号错误,然后让它重新构建,看看还剩下多少错误。

As for the String types not allowed (at 'layout_width' with value 'match_parent') a quick search on * says that its caused because FILL_PARENT was replaced with MATCH_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.

对于不允许的字符串类型(在'layout_width'和值'match_parent'),在*上进行快速搜索,就会发现这是因为在Android 2.2中FILL_PARENT被match_parent替换而导致的。因此,需要将项目的sdk设置为Android 2.2或更高版本。这是这个问题的链接。

#3


0  

This happened to me in importing the wiktionary sample and i found the solution.

我在导入wiktionary样本时遇到了这个问题,我找到了解决方案。

  1. Import the project through existing code
  2. 通过现有代码导入项目
  3. Right click project and choose properties
  4. 右键单击项目并选择属性
  5. In 'Android' Tab the default choice is the minimum API. Changed it to the latest(highest API)
  6. 在“Android”选项卡中,默认选项是最小API。将它更改为最新的(最高的API)
  7. Click ok.
  8. 单击ok。
  9. Clean and build your project and errors will be gone
  10. 清理并构建项目,错误就会消失

(probably optional) 6. Change the target and Minimum SDK in the Android Manifest

(可能是可选的)6。更改Android Manifest中的目标和最小SDK

#1


6  

Step #1: Start a new Android project

第一步:启动一个新的Android项目

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

步骤2:在Android项目向导的第一页,选择“从现有源创建项目”单选按钮,然后单击Browse按钮,找到包含项目的目录

Step #3: Tweak settings to suit, then press Finish

步骤#3:调整设置以适应,然后按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

步骤#4:如果需要(不确定是否还需要),右键单击项目名称,从上下文菜单中选择Build Path >配置构建路径,并确保检查清单中的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.

例如,您涉及添加格式化=“false”的问题非常常见,这是由于aapt的严格性发生了变化,这个问题在本问题中得到了解释。很可能示例项目是在更改之前创建的,之后没有更新。

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 error No resource found that matches the given name (at 'hint' with value '@string/search_hint') and others like it are often due to the formatted="false" error. I would suggest fixing all the % sign errors with the formatted="false" then letting it rebuild and see how many errors are left.

涉及到formatting ="false"的错误也会导致更多的错误,因为在这个错误之后的任何xml通常都不会被解析,因此在这个错误之后声明的任何资源都是未知的。因此,没有找到匹配给定名称的错误(在'hint'与值'@string/search_hint')和其他类似的错误通常是由于格式化="false"错误造成的。我建议用format ="false"修改所有的%符号错误,然后让它重新构建,看看还剩下多少错误。

As for the String types not allowed (at 'layout_width' with value 'match_parent') a quick search on * says that its caused because FILL_PARENT was replaced with MATCH_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.

对于不允许的字符串类型(在'layout_width'和值'match_parent'),在*上进行快速搜索,就会发现这是因为在Android 2.2中FILL_PARENT被match_parent替换而导致的。因此,需要将项目的sdk设置为Android 2.2或更高版本。这是这个问题的链接。

#3


0  

This happened to me in importing the wiktionary sample and i found the solution.

我在导入wiktionary样本时遇到了这个问题,我找到了解决方案。

  1. Import the project through existing code
  2. 通过现有代码导入项目
  3. Right click project and choose properties
  4. 右键单击项目并选择属性
  5. In 'Android' Tab the default choice is the minimum API. Changed it to the latest(highest API)
  6. 在“Android”选项卡中,默认选项是最小API。将它更改为最新的(最高的API)
  7. Click ok.
  8. 单击ok。
  9. Clean and build your project and errors will be gone
  10. 清理并构建项目,错误就会消失

(probably optional) 6. Change the target and Minimum SDK in the Android Manifest

(可能是可选的)6。更改Android Manifest中的目标和最小SDK