3

I have a Java program, written in Eclipse, which I would like to change to an Android app. Therefore, as a first step I would like to convert the corresponding Java project to an Android project which I can run either in Eclipse with the ADT plug-in or in Android Studio.

This appears to be a common problem. The first guide I read was not useful as it only contained one example. Then, this question has been asked twice here on this network, with (apparently) no satisfactory answers (so I assume it is acceptable to ask again):

The first answers covers four possible solutions, but as noted in the comment, none of them seem to work currently. Selecting "Android > Convert to Android project" is not supported anymore with the ADT plug-in, as noted, and the other ways are not suitable or do not appear to work anymore.

The second and third answers here appears to be useful. As suggested, I added

<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>

to the .project file, when that alone did not work, I also added to the project file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.convertproject.test"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
</manifest>

and

target=android-7
android.library=true

Now, attempting to import my project in Android Studio (after restarting Android Studio) still results in the message:

[file name with directory] is an Eclipse project, but not an Android Eclipse project. Please select the directory of an Android Eclipse project (which for example will contain an AndroidManifest.xml file) and try again.

I do not understand why I get this message when I have already included the AndroidManifest code snipppet in the .project file. Unfortunately the same situation happens in Eclipse, selecting File -> New -> Project -> Android -> Android Project from Existing Code does not work since it does not find any Android project in the folder.

Are there any other lines which I also need to include in my .project file, are there any steps in this method which I am missing or does it simply not function anymore? Any help appreciated.

Community
  • 1
  • 1
Sid
  • 563
  • 1
  • 10
  • 28
  • the "Android Manifest" code should be in its own file - AndroidManifest.xml. Also unless the project is a library (as opposed to something that creates its own UI) it isn't just going to work once you change the project type, its a little more involved than that. – panini Jun 16 '14 at 01:52
  • @panini Thanks. Indeed it does create its own UI so I can imagine that the process is more involved. Do you know of any guide that could help me out or is the only way simply to start from scratch? – Sid Jun 16 '14 at 01:55
  • 4
    I think the easiest way to do it would be to start from scratch personally. Any business logic you have can be ported across as-is, but user interface stuff will have to be re-written (as the interaction method is completely different.) have a look at the [Android developer portal](http://developer.android.com/training/index.html) if you haven't already to see how Android does user interaction (also pay attention to the Activity lifecycle - this is very important) – panini Jun 16 '14 at 02:03

1 Answers1

6
 1. create a android project 
 2. Move your java files to "src" folder in your project.
likith sai
  • 527
  • 1
  • 6
  • 21