How to create a jar in Android studio?

How can an Eclipse project's nature be changed to an Android library without breaking the source control history?

  • I have forked a plain Java project from Git. It uses Android classes from the Android API, and manually added the Android jar from the SDK as a build dependency. I want to change this into an Android project, without having to create a new Android library project and copy the source code which will lose track of the source code's history. I am working with an application project that uses this library project, but I'm encountering: It seems Eclipse does not officially support this - are there good hacks? I'm using EGit but doing it on the command line would be fine.

  • Answer:

    Outside Eclipse, edit the .project file. Copy from an existing Android project, which will have: <buildSpec> <buildCommand> <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.android.ide.eclipse.adt.ApkBuilder</name> <arguments>e. </arguments> </buildCommand> </buildSpec> <natures> <nature>com.android.ide.eclipse.adt.AndroidNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> Edit the .classpath file. It should now contain the Android framework: <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> Create a default.properties file. It should be have at least: target=android-8 android.library=true Create a gen folder for the generated Android source code, and a res folder for resources, even if you have none, like for a source-code only library. Create an AndroidManifest.xml file that describes the library project, as documented in: http://developer.android.com/guide/developing/projects/projects-eclipse.html#SettingUpLibraryProject In the application project, refer to the library project as a reference, in the project properties.

Miguel Paraz at Quora Visit the source

Was this solution helpful to you?

Other answers

There should be an easy way: Java Project: save as Android Project. if(keyEvent==true) {saveAs(touchScreenEvent);} And that what I would expect from a way to transfer things.

Helder Peres

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.