Reputation: 573
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.
Upvotes: 3
Views: 4267
Reputation: 547
1. create a android project
2. Move your java files to "src" folder in your project.
Upvotes: 6