如何分发 Android 应用程序(以便人们看不到源代码)

发布于 2024-09-10 20:17:30 字数 127 浏览 2 评论 0原文

我有一些java代码想与一些同学分享,但我不想与他们分享源代码。

为某人提供可以使用但看不到源代码的 Java 可执行文件的标准方法是什么?

不确定这是否相关,但我将给他们的代码将在 Android 上运行。

I have some java code that I want to share with some classmates however I do not want to share the source with them.

What is the standard method to provide someone with a Java executable that they can use but they cannot see the source.

Not sure if this is relevant but the code that I will be giving them will be run on android.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

从来不烧饼 2024-09-17 20:17:31

仅将类文件打包到 .jar 文件中,并且不提供源代码。

编辑: Android 有自己的打包应用程序的方式,我建议使用它。

Package only the class files into a .jar file and don't give them the source.

Edit: Android has its own way of packaging applications, I would suggest using it.

心凉 2024-09-17 20:17:31

Android 不使用 Java 运行时。我只使用 Java 作为源语言,它使用自定义字节码格式运行自定义运行时。您可以反编译.dex字节代码,但至少不能反编译为Java源代码不是在发表这篇文章时。

Android doesn't use the Java runtime. I only uses Java as a source language, it runs a custom runtime with a custom bytecode format. You can decompile the .dex byte code, but not to Java source code, at least not at the time of this post.

毁梦 2024-09-17 20:17:30

这取决于“他们可以使用”的意思。

如果您只是希望他们能够在手机(或模拟器)上运行您的应用程序,您可以给他们 .apk 文件,这是 Android 应用程序的标准格式。生成 .apk 的最简单方法是使用 Eclipse 的 Android 开发工具 (ADT) 插件。否则,您必须使用 aapt 命令< /a>.

如果您想允许他们将您的类添加到他们的应用程序中,您必须向他们提供一个包含您编译的 .class 文件的 .jar 文件。但是,可以使用反编译器将 .class 文件转回 .java 文件,因此,如果您确实不想让他们看到您的代码,您可能会陷入困境。

有些工具(称为混淆器)会使反编译过程变得更加困难,但就我个人而言,我不会在这里打扰它们,因为它们也会使调试变得更加困难。

任何人都不可能将您的 .apk 转回源代码。 Android 使用与标准 Java 不同的虚拟机,因此具有带有 Dalvik 字节码的 .dex 文件,而不是带有 JVM 字节码的 .class 文件,并且目前没有工具可以将 < code>.dex 文件返回到 .java 源文件。

It depends on what you mean by "they can use".

If you just want them to be able to run your application on their phones (or emulators) you can give them an .apk file, which is the standard format for Android Applications. The easiest way to produce an .apk is to use the Android Development Tools (ADT) plugin for Eclipse. Otherwise you'll have to use the aapt command.

If you want to allow them to add your classes to their applications you'll have to give them a .jar file containing your compiled .class files. However, it is possible to turn .class files back into .java files using a decompiler so you if you really don't want them to see your code you may be stuck.

There are tools - known as obfuscators - which make the decompiling process harder, but personally I wouldn't bother with them here as they also make debugging harder too.

It won't be possible for anyone to turn your .apk back into source. Android uses a different Virtual Machine to standard Java and so has .dex files with Dalvik bytecode rather than .class files with JVM bytecode, and currently there are no tools that turn .dex files back in to .java source files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文