如何将 jar 添加到 APK &让 APK 在没有 Eclipse 的情况下引用它? [英] How can I add a jar to an APK & make the APK refer to it without Eclipse?

查看:26
本文介绍了如何将 jar 添加到 APK &让 APK 在没有 Eclipse 的情况下引用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来有点奇怪,但我需要实现它.

This may seem a bit weird, but I need to implement it.

我有一个 APK &我没有有它的源代码.现在我可以破解 apk ,修改 &重新打包它,但在这样做的同时,我需要将我的自定义 jar 添加到其中 &使应用程序/apk 在运行时引用此库/jar.

I have an APK & I dont have its source code. Now I can break the apk , modify & repack it, but while doing so, I need to add my custom jar to it & make the app/apk refer this library/jar at run time.

如果我只是在 apk & 中创建一个文件夹 libs把我的罐子放进去,我得到一个 NoClassDefFound 错误.

If I just create a folder libs inside the apk & put my jar inside, I get a NoClassDefFound error.

知道如何使用 ANT 或任何其他工具来实现它吗?提前谢谢

Any idea how to implement it using ANT or any other tool ? Thanx in advance

推荐答案

您在 android 项目中附加的 Jar(s) 不会复制到 APK 中.

The Jar(s) you attach in your android project, are not copied into APK.

结果是,您的 Jar(s) 文件的代码成为您的 Android 代码的一部分.这意味着您不能简单地在 APK 中放置(或复制)Jar 文件.

What happens is that, The code of your Jar(s) file becomes part of your Android code. That means you can not simply place(or copy) Jar files in your APK.

但是,有办法解决.在 APK 中,您的源代码可以在 classes.dex 文件中找到.

But, There is a way around. In APK, your source code can be found in the classes.dex file.

您需要做的是,按照步骤操作

What you need to do is, follow the steps

1 - 使用 winRAR 提取 APK

1 - Extract APK using winRAR

2 - 使用 dex2jar

3 - 提取 Jar 文件

3 - Extract Jar file

4 - 您将拥有 *.class 中的源代码,您可以使用 JdGUI 将其转换为 *.java.

4 - You will have source code in *.class, You can use JdGUI to convert it to *.java.

现在,您可以创建新的 android 项目并使用代码.

Now, you can create new android project and use the code.

这篇关于如何将 jar 添加到 APK &让 APK 在没有 Eclipse 的情况下引用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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