简体   繁体   中英

Packaging android code into jar file

I am trying to package the android code into a jar file so that I can use it in another project. But when I do that I get the following error messages. I am not sure how to do this correctly if someone has done it please post a link and some details would be really helpful.

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 have to use it in lots of project so I want to compile it as jar just like other libraries available online such as twitter4j, googleAnalytic, androidsupportlibrary and I need to know which folder are compulsory to include in Jar file. I have tried building it by excluding the resources folder and using eclipse->export, though it builds the jar but upon including it in another test project displays the above errors messages.

Better to build as a Library Project. Right click the Project( which is having common code) -> Select Properties -> Select Android Tab ->check isLibrary Option-> Ok as shown below : 在此输入图像描述 . You can add this as referenced project to another Project by clicking Add button in the above image. Then the Library Projects directory is created having jar file as shown below :

在此输入图像描述

that error occurs when your content doesn't contain a purely java files!!

If your "own classes" are purely Java, create a JAR file, and add that JAR file to whichever Android projects you want it in (put it in libs/ of the project, and also add it to your build path if you are using Eclipse). If you will be needing Android resources and such, though, you can create an Android library project, either for Eclipse or outside of Eclipse .

Or Project Properties -> Select Android Tab ->check isLibrary Option->Ok

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM