14

I have an Android Eclipse project and an associated Android Test Eclipse project checked into a subversion repository. Given a checked out working copy, how do I bring the Android Test project into an Eclipse workspace?

It's easy to add the Android project to the workspace (just File->New Project->Android Project->From Existing Source and point it at the directory in the svn working copy). But, the 'New Android Test Project' does not have an option to create from existing source.

4 Answers 4

13
  1. File -> Import...
  2. Existing Android Code into Workspace
  3. Import the project as you would with a regular Android project
  4. You'll have errors becase the imported test project does not have references to the parent project
  5. Right Click test project -> Properties
  6. Java Build Path -> Projects tab
  7. Add -> Choose the project that you're testing
  8. Ok
  9. Refresh / Clean (optional)
  10. Right Click test project -> Run As -> Android JUnit Test
1
  • 11. (Change "Java Compiler" → "Compiler compliance settings" to 1.6) or ("Android Tools" → "Fix Project Properties")
    – Rayne
    Jan 25, 2014 at 21:48
8

Was searching for this functionality and didn't find it either :)

What I did in the end is this:

  1. Moved my existing test project directory (checked out from version control) to a temp dir
  2. In Eclipse I created a new empty Android Unit Test project, located it in the directory with the name of the original test project directory
  3. Closed Eclipse and copied a .classpath and .project files from newly created test project to a current root directory of old test project (in a temp dir)
  4. Removed a new empty test project directory, moved old one from temp location back to original location

Simply put, I just generated new .classpath and .project files and copied them to checked out project dir.

After cleaning and refreshing in Eclipse this worked out :) Of course this is not a real solution, but an ugly workaround which I even don't expect to work in any situation, but who knows, might help you. Cheers.

1

I think you want Import > Existing project, especially if the .project and .classpath files are checked into version control.

1
  • I'm hoping for a method to do this that doesn't require checking in the .project and .classpath files. For a non-test Android project, Google seems to have improved over by default Eclipse behavior by not requiring the .project and .classpath to be versioned.
    – David B.
    Sep 16, 2010 at 6:46
0

I also had to R. click the test app (after importing as a normal Existing Android app) -> Properties -> Resource -> Android -> check the appropriate emulated Android box to get the Android JUnit Test option for running/debugging which was otherwise missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.