加密 .class 文件后无法 jar
我已经加密了 .class 文件,并想将它们打包,以便我可以使用 dexclassloader 来加载它们。虽然我遇到的问题是我使用 ant
(build.xml
[dx 命令])来 jar 它们,但它会出错。
[echo] Converting compiled files and external libraries into D:\XXX/classes.dex...
[apply] trouble processing:
[apply] bad class file magic (6244b7bf) or version (e2dd.0927)
[apply] ...while parsing com/XXX/LibraryProvider.class
[apply] ...while processing com/XXX/LibraryProvider.class
[apply] 1 warning
[apply] no classfiles specified
我加密后,.class
文件似乎是坏的。我该如何解决这个问题?
I have encrypted .class files and would like to jar them so that I could use dexclassloader to load them.While the problem I get is that I use ant
(build.xml
[dx command]) to jar them ,but it makes error.
[echo] Converting compiled files and external libraries into D:\XXX/classes.dex...
[apply] trouble processing:
[apply] bad class file magic (6244b7bf) or version (e2dd.0927)
[apply] ...while parsing com/XXX/LibraryProvider.class
[apply] ...while processing com/XXX/LibraryProvider.class
[apply] 1 warning
[apply] no classfiles specified
It seems like .class
file is bad after I encrypted them. How can I solve the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
摆脱加密。
首先,这种加密在常规 Java 上毫无意义,更不用说安卓了。
其次,对于 Android,您的
.class
文件将仅存在于您的开发计算机上。 Android APK 文件不包含带有 JVM 字节码的.class
文件。 APK 文件将包含 Dalvik 字节码;构建工具将您的.class
文件交叉编译为 Dalvik 字节码。通过加密这些类文件,构建工具将无法使用它们。欢迎您使用 ProGuard 来混淆您的 Java 字节码,因为这仍然会生成构建工具能够理解的
.class
文件。 Proguard 已集成到 Android 构建链中。Get rid of the encryption.
First, such encryption is pointless on regular Java, let alone Android.
Second, for Android, your
.class
files will only ever exist on your development machine. Android APK files do not contain your.class
files with JVM bytecode. The APK files will contain Dalvik bytecode; the build tools cross-compile your.class
files to Dalvik bytecode. By encrypting those class files, the build tools cannot use them.You are welcome to use ProGuard to obfuscate your Java bytecode, as that still results in
.class
files that the build tools will understand. Proguard is integrated into the Android build chain.