混淆时遇到麻烦

发布于 2024-07-24 02:27:44 字数 983 浏览 6 评论 0原文

我正在使用 Antenna 来构建、打包和混淆 j2me 应用程序。 构建和包装工作正常。

该项目使用了第 3 方 jar,除了某些接口之外,该 jar 已经被混淆了。

当尝试混淆时,我遇到了几个错误,例如:

[wtkobfuscate] Warning: i: can't find referenced class fooPackage.fooClass

Class i 和 fooPackage.fooClass 来自我提到的第 3 方 jar。

更新

此第 3 方库使用 j2me-xmlrpc.jar。 如果我不将所有内容打包在一起,那么我将无法混淆第 3 方接口和 j2me-xmlrpc.jar。 (而且我无法以这种方式运行应用程序,不知道为什么)

如果我只打包 j2me-xmlrpc.jar 和我的项目类,我会在混淆

[wtkobfuscate] Warning: there were 2 instances of library classes depending on program classes.

UPDATE 2:

时收到此错误:我知道这一点混淆是可能的,因为在 Netbeans 中我可以使用 Proguard 进行混淆。

由于 Netbeans 内部使用 ANT 进行构建,因此我尝试将生成的 build.xml 复制到我自己的 build.xml 中。

为了进行混淆,Netbeans 使用可在 Netbeans 外部使用的库 org-netbeans-modules-mobility-antext.jar。 我将此库导入到我的项目中并使用它没有问题。

但我得到了与使用天线相同的错误。

在 Netbeans 中进行混淆会生成大量警告,但仍然会生成混淆的 jar。

我缺少什么?

I'm using Antenna to build, pack and obfuscate a j2me app.
Building and packing works fine.

The project uses a 3rd party jar that is already obfuscated except by some interfaces.

When trying to obfuscate I got several errors like:

[wtkobfuscate] Warning: i: can't find referenced class fooPackage.fooClass

Class i and fooPackage.fooClass is from this 3rd party jar that I mentioned.

UPDATE:

This 3rd party library uses j2me-xmlrpc.jar. If I don't package all together then I won't be able to obfuscate the 3rd party interfaces and the j2me-xmlrpc.jar. (and I can't run the app this way, not sure why)

If I package only the j2me-xmlrpc.jar and my project classes I get the this error while obfuscating

[wtkobfuscate] Warning: there were 2 instances of library classes depending on program classes.

UPDATE 2:

I know this obfuscation is possible beacause in Netbeans I can do obfuscation using Proguard.

Since Netbeans internals uses ANT to make builds I tried to copy the generated build.xml to my own build.xml.

For obfuscation Netbeans uses the library org-netbeans-modules-mobility-antext.jar that can be used outside Netbeans. I imported this library to my project and used it without problem.

But I get the same error I got using antenna.

Obfuscating in Netbeans generates a lot of warnings but it still generates the obfuscated jar.

What I'm missing?

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

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

发布评论

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

评论(3

暮年 2024-07-31 02:27:45

尝试使用 jshrink。 我用它得到的结果比用 proguard 好得多:

                    <java jar="obfuscator\jshrink.exe" fork="true">
                        <arg value="..\${projectdir}\${projectname}.jar"/>
                        <arg value="-classpath"/>
                        <arg pathref="project.class.path"/>
                        <arg value="-keep"/>
                        <arg value="${midletclass}"/>
                        <arg value="-o"/>
                        <arg value="..\${projectdir}\${projectname}.jar"/>
                    </java>

try using jshrink. I have much better results with it then with proguard:

                    <java jar="obfuscator\jshrink.exe" fork="true">
                        <arg value="..\${projectdir}\${projectname}.jar"/>
                        <arg value="-classpath"/>
                        <arg pathref="project.class.path"/>
                        <arg value="-keep"/>
                        <arg value="${midletclass}"/>
                        <arg value="-o"/>
                        <arg value="..\${projectdir}\${projectname}.jar"/>
                    </java>
人心善变 2024-07-31 02:27:44

如果第 3 方库被混淆,则在混淆类时不要包含该库。 相反,请按照以下步骤

  1. 单独打包您的类(不包括第 3 方库)
  2. 混淆步骤 1 中获得的 jar
  3. 将步骤 2 中获得的混淆后的 jar 和某些临时文件夹中的第 3 方库解压缩
  4. 将所有未打包的类打包
  5. 再次预验证并打包它们

If the 3rd party library is obfuscated, don't include that library while you obfuscate your classes. Rather follow these steps

  1. Jar your classes alone (dont include 3rd party library)
  2. Obfuscate the jar obtained in step 1
  3. Unjar the obfuscated jar obtained in step 2 and the 3rd party library in some temp folder
  4. Jar all the unjared classes
  5. Preverify and package them again
始于初秋 2024-07-31 02:27:44

我使用的是 Proguard 4.3。 降级到 Proguard 4.2 解决了这个问题。

I was using Proguard 4.3. Downgrading to Proguard 4.2 solved the problem.

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