如何转换一个Android库项目到外部JAR? [英] How to Convert an Android Library Project to an External JAR?

查看:144
本文介绍了如何转换一个Android库项目到外部JAR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android库项目已为我工作pretty的很好,但我现在感兴趣的是转化到外部JAR。

我该怎么办呢?

可以在任何Android的库项目转换为外部JAR?如果不是,有什么要求和限制?

解决方案
  

可以在任何Android的库项目转换为外部JAR?

现在不行。

  

如果不是,有什么要求和限制?

如果你的库是纯Java的code,没有资源,你可以创建一个JAR出的的.class 文件,就像你用普通的Java

如果您的库使用的资源,你仍然可以创建一个JAR如上。但是,你需要查找研究值( R.layout.main 如)通过反射或则getIdentifier(),和你的资源不会被打包在JAR但必须另行分配。

在未来,构建工具应该支持创建分发的JAR文件出库项目,完成资源。目前构建工具确实创造了JAR文件,但它们不是设计为分发,但相当内部生成工件的时刻。

I have an Android library project that has been working for me pretty well, but now I am interested in "converting" it to an external JAR.

How do I do that?

Can any Android library project be converted to an external JAR? If not, what are the restrictions or limitations?

解决方案

Can any Android library project be converted to an external JAR?

Not right now.

If not, what are the restrictions or limitations?

If your library is purely Java code, with no resources, you can create a JAR out of the .class files, just as you would with regular Java.

If your library uses resources, you can still create a JAR as above. However, you will need to look up the R values (e.g., R.layout.main) via reflection or getIdentifier(), and your resources will not be packaged in the JAR but would have to be distributed separately.

In the future, the build tools should support creating distributable JAR files out of library projects, complete with resources. The current build tools do create JARs, but they are not designed to be distributed but are rather internal build artifacts at the moment.

这篇关于如何转换一个Android库项目到外部JAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆