How to deal with missing src/test/java source folder in Android/Maven project?
Solution 1
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).
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:
<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:
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.
Solution 2
We can add java folder from
- Build Path -> Source.
- click on Add Folder.
- Select main as the container.
- click on Create Folder.
- Enter Folder name as java.
- Click on Finish
It works fine.
Solution 3
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 .
Solution 4
This is possibly caused due to lost source directory.
Right click on the folder src -> Change to Source Folder
Solution 5
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.
Bevor
Updated on December 19, 2021Comments
-
Bevor over 2 years
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:
Project 'xxx-1.0-SNAPSHOT' is missing required source folder: '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:
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?
I'm using Eclipse Juno, m2e 1.1.0, Android Configuration for m2e 0.4.2.
-
Bevor almost 12 yearsThanks, I will try that when I'm at home tonight. Is there actually no way to tell the android archetype to generate src/test/java?
-
Ricardo Gladwell almost 12 yearsThere is an open ticket to add this folder to the Android archetypes project: github.com/akquinet/android-archetypes/issues/34
-
jeremyjjbrown over 10 yearsThis worked for me. What a ridiculous problem to have release after release.
-
Ortwin Angermeier about 8 yearsExecute the following in the root dir:
mkdir -p src/{main,test}/{java,resources}
then press ALT + F5 -
ruhong over 7 yearsIn the build path --> Source, my
src/test/java
was marked as missing. So I removed the folder and created a new one with the same name. This worked for me. -
Martijn Courteaux over 6 yearsThis... This must be joke. I'm sure this font is a joke.
-
Raman over 3 yearsthis is awesome! @wejack