I'm not very experienced with Maven in combination with Android yet, so I followed these instructions to make a new Android project. When the project has been created, I get the following error message:
我对Maven与Android结合的经验还不是很丰富,所以我按照这些说明做了一个新的Android项目。当项目创建后,我得到以下错误消息:
Project 'xxx-1.0-SNAPSHOT' is missing required source folder: 'src/test/java'
项目“xxx-1.0 snapshot”缺少所需的源文件夹:“src/test/java”
When I try to add a new source folder with New->Other->Java-Source Folder with src/test/java, I get another error message:
当我尝试添加一个新的-> -> java - source文件夹和src/test/java的新源文件夹时,我得到了另一个错误信息:
The folder is already a source folder.
该文件夹已经是一个源文件夹。
But I don't have any src/test/java folder in my project. How should I deal with that? What's the clean way to setup the project, because I assume that there is something missing in this instruction. So what is the Maven way to let src/test/java appear?
但是我的项目中没有任何src/test/java文件夹。我该怎么处理呢?什么是建立项目的干净方式,因为我假设这个指令中缺少了一些东西。那么,让src/test/java出现的Maven方式是什么呢?
I'm using Eclipse Juno, m2e 1.1.0, Android Configuration for m2e 0.4.2.
我正在使用Eclipse Juno, m2e 1.1.0, m2e 0.4.2的Android配置。
7 个解决方案
#1
78
I realise this annoying thing too since latest m2e-android plugin upgrade (version 0.4.2), it happens in both new project creation and existing project import (if you don't use src/test/java).
自从最新的m2e-android插件升级(版本0.4.2)以来,我也意识到这个烦人的事情,它发生在新项目创建和现有项目导入(如果不使用src/test/java)中。
It looks like m2e-android (or perhaps m2e) now always trying to add src/test/java
as a source folder, regardless of whether it is actually existed in your project directory, in the .classpath file:
看起来m2e-android(或者m2e)现在总是试图添加src/test/java作为源文件夹,不管它是否实际存在于您的项目目录中,在.classpath文件中:
<classpathentry kind="src" output="bin/classes" path="src/test/java">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
As it is already added in the project metadata file, so if you trying to add the source folder via Eclipse, Eclipse will complain that the classpathentry is already exist:
由于它已经添加到项目元数据文件中,所以如果您试图通过Eclipse添加源文件夹,Eclipse将会抱怨classpathentry已经存在:
There are several ways to fix it, the easiest is manually create src/test/java directory in the file system, then refresh your project by press F5 and run Maven -> Update Project (Right click project, choose Maven -> Update Project...), this should fix the missing required source folder: 'src/test/java' error.
有几种方法可以修复它,最简单的方法是在文件系统中手动创建src/test/java目录,然后按F5刷新项目并运行Maven ->更新项目(右键单击项目,选择Maven ->更新项目……),这应该可以修复丢失的所需的源文件夹:“src/test/java”错误。
#2
11
We can add java folder from
我们可以从其中添加java文件夹
- Build Path -> Source.
- 构建路径- >来源。
- click on Add Folder.
- 点击添加文件夹。
- Select main as the container.
- 选择main作为容器。
- click on Create Folder.
- 点击创建文件夹。
- Enter Folder name as java.
- 输入文件夹名称为java。
- Click on Finish
- 单击Finish
It works fine.
它将正常工作。
#3
4
I solve the problem by creating a folder named "src/test/resources" first, then i rename the folder to "src/test/java" ,finally create a "src/test/resources" folder again .It works .
我先创建一个名为“src/test/resources”的文件夹,然后将文件夹重命名为“src/test/java”,最后再创建一个“src/test/resources”文件夹。
#4
2
This is possibly caused due to lost source directory.
这可能是由于源目录丢失造成的。
Right click on the folder src -> Change to Source Folder
右键单击文件夹src ->更改为源文件夹
#5
2
I had the same issue, fixed it. Create the missing folder directly in your file system (Using windows explorer for example) . And then, refresh your project under eclipse.
我有同样的问题,解决了。直接在文件系统中创建丢失的文件夹(例如使用windows资源管理器)。然后,在eclipse中刷新项目。
#6
1
This is a bug in the Android Connector for M2E (m2e-android) that was recently fixed:
这是最近修复的M2E (M2E - Android) Android连接器中的一个bug:
https://github.com/rgladwell/m2e-android/commit/2b490f900153cd34fff1cec47fe5aeffabe44d87
https://github.com/rgladwell/m2e-android/commit/2b490f900153cd34fff1cec47fe5aeffabe44d87
This fix has been merged and will be available with the next release. In the meantime you can test the new fix by installing from the following update site:
此修复已被合并,并将在下一个版本中提供。在此期间,您可以通过安装以下更新站点来测试新的修复:
http://rgladwell.github.com/m2e-android/updates/master/
http://rgladwell.github.com/m2e-android/updates/master/
#7
0
Removing the m2 plugin from startup-up plugin's list and doing a Maven->Update Projects on all the projects worked for me.
从startupup插件列表中删除m2插件,并对所有项目执行Maven->更新项目。
Note** One should not create additional folders to avoid merging them while using SVN/Git based branches.
注意**在使用基于SVN/Git的分支时,不应该创建其他文件夹以避免合并它们。
#1
78
I realise this annoying thing too since latest m2e-android plugin upgrade (version 0.4.2), it happens in both new project creation and existing project import (if you don't use src/test/java).
自从最新的m2e-android插件升级(版本0.4.2)以来,我也意识到这个烦人的事情,它发生在新项目创建和现有项目导入(如果不使用src/test/java)中。
It looks like m2e-android (or perhaps m2e) now always trying to add src/test/java
as a source folder, regardless of whether it is actually existed in your project directory, in the .classpath file:
看起来m2e-android(或者m2e)现在总是试图添加src/test/java作为源文件夹,不管它是否实际存在于您的项目目录中,在.classpath文件中:
<classpathentry kind="src" output="bin/classes" path="src/test/java">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
As it is already added in the project metadata file, so if you trying to add the source folder via Eclipse, Eclipse will complain that the classpathentry is already exist:
由于它已经添加到项目元数据文件中,所以如果您试图通过Eclipse添加源文件夹,Eclipse将会抱怨classpathentry已经存在:
There are several ways to fix it, the easiest is manually create src/test/java directory in the file system, then refresh your project by press F5 and run Maven -> Update Project (Right click project, choose Maven -> Update Project...), this should fix the missing required source folder: 'src/test/java' error.
有几种方法可以修复它,最简单的方法是在文件系统中手动创建src/test/java目录,然后按F5刷新项目并运行Maven ->更新项目(右键单击项目,选择Maven ->更新项目……),这应该可以修复丢失的所需的源文件夹:“src/test/java”错误。
#2
11
We can add java folder from
我们可以从其中添加java文件夹
- Build Path -> Source.
- 构建路径- >来源。
- click on Add Folder.
- 点击添加文件夹。
- Select main as the container.
- 选择main作为容器。
- click on Create Folder.
- 点击创建文件夹。
- Enter Folder name as java.
- 输入文件夹名称为java。
- Click on Finish
- 单击Finish
It works fine.
它将正常工作。
#3
4
I solve the problem by creating a folder named "src/test/resources" first, then i rename the folder to "src/test/java" ,finally create a "src/test/resources" folder again .It works .
我先创建一个名为“src/test/resources”的文件夹,然后将文件夹重命名为“src/test/java”,最后再创建一个“src/test/resources”文件夹。
#4
2
This is possibly caused due to lost source directory.
这可能是由于源目录丢失造成的。
Right click on the folder src -> Change to Source Folder
右键单击文件夹src ->更改为源文件夹
#5
2
I had the same issue, fixed it. Create the missing folder directly in your file system (Using windows explorer for example) . And then, refresh your project under eclipse.
我有同样的问题,解决了。直接在文件系统中创建丢失的文件夹(例如使用windows资源管理器)。然后,在eclipse中刷新项目。
#6
1
This is a bug in the Android Connector for M2E (m2e-android) that was recently fixed:
这是最近修复的M2E (M2E - Android) Android连接器中的一个bug:
https://github.com/rgladwell/m2e-android/commit/2b490f900153cd34fff1cec47fe5aeffabe44d87
https://github.com/rgladwell/m2e-android/commit/2b490f900153cd34fff1cec47fe5aeffabe44d87
This fix has been merged and will be available with the next release. In the meantime you can test the new fix by installing from the following update site:
此修复已被合并,并将在下一个版本中提供。在此期间,您可以通过安装以下更新站点来测试新的修复:
http://rgladwell.github.com/m2e-android/updates/master/
http://rgladwell.github.com/m2e-android/updates/master/
#7
0
Removing the m2 plugin from startup-up plugin's list and doing a Maven->Update Projects on all the projects worked for me.
从startupup插件列表中删除m2插件,并对所有项目执行Maven->更新项目。
Note** One should not create additional folders to avoid merging them while using SVN/Git based branches.
注意**在使用基于SVN/Git的分支时,不应该创建其他文件夹以避免合并它们。