Packing Android code in jar file

I am trying to pack Android code in a jar file so that I can use it in another project. But when I do this, I get the following error messages. I am not sure how to do it right, if someone has done this, send a link, and some details will be really useful.

thanks

Error generating final archive: Found duplicate file for APK: AndroidManifest.xml Origin 1: C:\Users\Admin\workspace\Test\bin\resources.ap_ Origin 2: C:\Users\Admin\workspace\Test\lib\JarLib.jar 

I need to use it in many projects, so I want to compile it as a jar, like other libraries available on the Internet, such as twitter4j, googleAnalytic, androidsupportlibrary, and I need to know which folder is required to be included in the Jar file. I tried to create it by excluding the resource folder and using eclipse-> export, although it creates a jar, but when I include it in another test project, the above error messages are displayed.

+6
source share
2 answers

this error occurs when your content does not contain pure java files!

If your "native classes" are pure Java, create a JAR file and add this JAR file depending on which Android projects you want to use (put it in the libs / projects and add it to your build path if you use Eclipse). If you need Android resources, etc., you can create an Android library project, either for Eclipse or outside of Eclipse .

Or Project Properties -> Select the Android tab -> check the isLibrary Option -> Ok

+1
source

Better build as a library project. Right-click on the project (which has a common code) → Choose Properties → Select the Android tab → check isLibrary . Option → Ok , as shown below: enter image description here . You can add this as a project with reference to another project by clicking the Add button in the image above. Then, the Library Projects directory is created with the jar file, as shown below:

enter image description here

+2
source

Source: https://habr.com/ru/post/915973/


All Articles