出口的Android库项目重复使用而源$ C $ C [英] Export android library project for reuse without source code
问题描述
我需要导出库项目没有源$ C $ C出于安全原因。不幸的是,库项目中产生的jar文件不包含资源。我不能指望这个库的用户处理所需的库中的任何资源。
I need to export a library project without the source code for security reasons. Unfortunately the jar file generated within a library project does not contain the resources. I cannot expect the users of this library to deal with any resources needed by the library.
已经有类似的帖子这一个,但我还没有看到一个解决方案。
There have been similar post to this one, but I am yet to see a solution.
推荐答案
用来工作,虽然我还没有尝试过它最近以下几招:
The following recipe used to work, though I have not tried it very recently:
第1步:获取库项目工作原样。我将把目录拿着这个项目作为 $ ORIG
。
Step #1: Get the library project working as-is. I will refer to the directory holding this project as $ORIG
.
步骤#2:使用如果您还没有这样做的话,在 $ ORIG
创建Ant构建脚本 Android的更新项目
。
Step #2: If you have not done so already, create your Ant build scripts in $ORIG
using android update project
.
第三步:添加一个任务, $ ORIG / build.xml文件
创建一个JAR文件,是这样的:
Step #3: Add a task to $ORIG/build.xml
that creates a JAR file, something like:
<target name="jar" depends="debug">
<jar
destfile="bin/YOUR-LIBRARY-NAME-GOES-HERE.jar"
basedir="bin/classes"
/>
</target>
第四步:从 $ ORIG
整个库项目复制到另一个目录,我称之为 $ DIST
。
Step #4: Copy your entire library project from $ORIG
into another directory, which I'll call $DIST
.
第五步:获取摆脱
的除了根的src /
树$ DIST 的src /
目录本身。
Step #5: Get rid of the src/
tree in $DIST
except for the root src/
directory itself.
步骤#6:移动斌/你-LIBRARY-NAME GOES-HERE.jar
到 $ DIST /库/
。这将有效地取代了源$ C $从的src /
下与它同等编译。
Step #6: Move bin/YOUR-LIBRARY-NAME-GOES-HERE.jar
into $DIST/libs/
. This effectively replaces your source code from src/
with its compiled equivalent.
步骤#7:摆脱 $ DIST /斌/
,因为它不再需要
Step #7: Get rid of $DIST/bin/
as it is no longer needed.
$ DIST
现在拥有一个Android库项目,是 $ ORIG
相当于,除了的src /
树被替换库/您的-LIBRARY-NAME GOES-HERE.jar
。
$DIST
now holds an Android library project that is the equivalent of $ORIG
, except that the src/
tree is replaced by libs/YOUR-LIBRARY-NAME-GOES-HERE.jar
.
由于谷歌在SDK管理器中播放服务包打包这样一来,不仅我认为配方仍然有效,但它似乎是合理的正式批准。
Since the Google Play Services package from the SDK Manager is packaged this way, not only do I assume the recipe still works, but it would appear to be reasonably officially endorsed.
请注意,有新的构建系统之中,这可能给我们更多的选择在这里。如果你正在阅读这个问题,譬如说,2014年时,一定要检查,看看是否有更好的选择。
Note that there is new build system in the works that may give us more options here. If you are reading this question in, say, 2014, be sure to check to see if there are better alternatives.
这篇关于出口的Android库项目重复使用而源$ C $ C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!