- Remove mainfest.xml and res/*.
- eclipse -> export -> JAVA -> JAR file
- "Select the resources to export:" 下的項目皆不選 (ex: .classpath, .project, AndroidManifest.xml, default.properties, res, assets)
- "Next"
- "Finish"
Update on 20111106
* Cannot include AndroidManifest.xml or you will get this exception.
Error generating final archive: Found duplicate file for APK: AndroidManifest.xml
Origin 1: (#project path)\bin\resources.ap_
Origin 2: (#store JAR path)\Test.jar
* Or include the duplicate res will get this exception.
include res may duplicate with user
Error generating final archive: Found duplicate file for APK: res/layout/main.xml
Origin 1: (#project path)\bin\resources.ap_
Origin 2: (#store JAR path)\Test.jar
* Test including strings.xml
- If include strings.xml in Jar
- It won't be compiler and keep in Main Project apk.
- Main Project cannot find the string resource id that belong to Jar or get the string in Main Project that resource id is equal to.
- If try to access it will get exception:
- Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f040002
- If using open project to be library
- strings.xml will compiler with Main Project and export.
- So could get the string in library by JAR's namespace.
* Reference
- Android如何将程序打成jar包 | 第三极 | 移动开发者
- web_surf - ChinaUnix博客 - IT人与你分享快乐生活
- android中生成和使用jar 分享 - 黑暗任务 - ITeye技术网站 **
沒有留言:
張貼留言