How do you convert an existing project into an Android project in Eclipse?
In particular, I want to convert a plain old Java project into an Android Library project.
Thanks.
Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.
To use your Android library's code in another app module, proceed as follows: Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Library Dependency in the dropdown. In the Add Library Dependency dialog, use the search box to find the library to add.
You need to change the nature of the project (this has already been answered, but nobody gave the actual string you need for that.)
Make the natures section look like:
<natures> <nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures>
Start eclipse again, have fun.
Note: If you are using maven you can configure the project's nature in your pom, see the maven eclipse plugin doc
I had an app that was built with Eclipse 3.5 and used java projects instead of properly built Android Library projects. I'm not sure how it originally worked (the app was published and worked fined), but I couldn't get it to run when I tried setting up a dev environment on a different machine. I keep getting ClassNotFoundExceptions for references to the Java project.
Since I had a couple years of check-in history, I really didn't want to move projects as some answers stated. For me, converting the Java project into a proper Android Library made more sense.
Here are the steps I had to take to get it working:
Add AndroidNature to ".project" file
<natures> <nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures>
Add a simple "AndroidManifest.xml"
<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>
Add a "project.properties" file
target=android-7 android.library=true
NOTE: when you add library to your main project, import using the Android / Libray tab (under project properties) instead of Java Build Path / Projects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With