How to deal with missing src/test/java source folder in Android/Maven project?

前端 未结 9 2260
梦如初夏
梦如初夏 2020-12-13 06:15

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 ge

相关标签:
9条回答
  • 2020-12-13 07:04

    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:

    enter image description here

    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.

    0 讨论(0)
  • 2020-12-13 07:04

    This is possibly caused due to lost source directory.

    Right click on the folder src -> Change to Source Folder

    0 讨论(0)
  • 2020-12-13 07:06

    We can add java folder from

    1. Build Path -> Source.
    2. click on Add Folder.
    3. Select main as the container.
    4. click on Create Folder.
    5. Enter Folder name as java.
    6. Click on Finish

    It works fine.

    0 讨论(0)
提交回复
热议问题