com.apple.eawt.Application 在混淆后不起作用 [英] com.apple.eawt.Application not working after obfuscation

查看:55
本文介绍了com.apple.eawt.Application 在混淆后不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 Java 编写了一个适用于 Mac OSx 和 Windows 的应用程序,但我是在 Windows 上开发的.因此,我使用 java.lang.reflect.* 来实现关于"和退出"处理程序而不会收到异常.

I have written an application in Java for both Mac OSx and Windows, but I've developed it on Windows. Therefore I used java.lang.reflect.* in order to implement the 'About' and 'Quit' handler without receiving exceptions.

我已将其导出为 Executable Jar,并且在两个操作系统上一切正常.但是,我想混淆应用程序,我正在使用 ProGaurd 来做到这一点.我已经指定了它在 Windows 上运行所需的库(rt.jar、jsse.jar、jce.jar)并且它在 Windows 上仍然可以正常工作,但是 ProGaurd 告诉我有两个未解析的类的动态引用或界面,并且混淆的应用程序在 Mac 上不再正常工作(关于和退出处理程序不起作用).

I've exported it as an Executable Jar and everything works fine on both operating systems. However, I want to obfuscate the application and I'm using ProGaurd to do so. I've specified the necessary libraries for it to work on Windows (rt.jar, jsse.jar, jce.jar) and it still does work fine on Windows, however ProGaurd is telling me that there is two unresolved dynamic references to classes or interfaces, and the obfuscated application no longer works properly on Mac (the About and Quit Handler don't work).

我在某处读到 ui.jar 是必需的,所以我从我的 Mac 复制它并在 ProGaurd 中指定它,但这似乎没有解决问题!任何解决方案都表示赞赏...

I read somewhere that the ui.jar was required, so I copied it accross from my Mac and specified it in ProGaurd but that did not seem to solve the problem! Any solutions appreciated then...

提前致谢

更新

我现在使用 AppleJavaExtensions 来实现使用 com.apple.eawt.Application 而不是反射的处理程序.但是,我仍然遇到完全相同的问题!这是我目前使用的代码:

I have now used AppleJavaExtensions in order to implement the handlers using com.apple.eawt.Application rather than reflect. However, I'm still getting the exact same problem! Here is the code that I am currently using:

package ap;
import com.apple.eawt.AboutHandler;
import com.apple.eawt.AppEvent;
import com.apple.eawt.AppEvent.QuitEvent;
import com.apple.eawt.Application;
import com.apple.eawt.QuitHandler;
import com.apple.eawt.QuitResponse;
import com.gui.Tabs;

public class xa implements AboutHandler, QuitHandler {

    // Constructor to register/install the necessary handler's
    public xa(){
        Application.getApplication().setAboutHandler(this);
        Application.getApplication().setQuitHandler(this);
    }

    // Implemented method to catch the About menu item
    @Override
    public void handleAbout(AppEvent.AboutEvent e) {
        Tabs.switchAbout();

    }

    // Implemented method to catch the Quit menu item
    @Override
    public void handleQuitRequestWith(QuitEvent arg0, QuitResponse arg1) {
        Tabs.quit();        
    }
}

而且我正在使用 ProGuard GUI 来混淆我的应用程序.在底部的 Obsfucation 'tab' 中,我添加了类 ap.xa 并指定它扩展/实现 AboutHandler, QuitHandler.我还添加了 Class com.gui.Tabs 但问题仍然存在.

AND I am using the ProGuard GUI to obfuscate my application. In Obsfucation 'tab' at the bottom I've added class ap.xa and specified that it extends/implements AboutHandler, QuitHandler. I've also added the Class com.gui.Tabs but it the problem still occurs.

推荐答案

哎呀,我已经解决了这个问题...... 而我只是犯了一个愚蠢的错误

Opps, I've solved the problem... And I only made a silly mistake

因为我使用的是 ProGuard GUI,所以我没有在添加屏幕中看到班级成员"部分.因此,虽然 ProGuard 没有混淆类本身,但它混淆了方法,因此侦听器不起作用.因此,我最终保留"了 ap.xa 及其所有方法(包含实际侦听器的类)和 com.apple.**(JavaAppleExtensions包)

Because I'm using the ProGuard GUI, I failed to see the "Class members" part in the addition screen. Therefore, whilst ProGuard wasn't obfuscating the class itself, it was obfuscating the methods, hence the listeners not working. So, I've ended up 'keeping' ap.xa and all it's methods (the class containing the actually listeners), and com.apple.** (the JavaAppleExtensions package)

然而,还有一件事正在发生.当我从终端运行混淆的 JAR 文件时,我收到以下输出:

However, there is still one thing occurring. When I run the obfuscated JAR file from Terminal I receive the following output:

Andrews-MacBook-Pro:~ Andy$ java -jar /Users/Andy/Desktop/YLIT\ Final\ 2.jar
Jun  9 20:50:29 Andrews-MacBook-Pro.local java[959] <Error>: CGContextGetCTM: invalid context 0x0
Jun  9 20:50:29 Andrews-MacBook-Pro.local java[959] <Error>: CGContextSetBaseCTM: invalid context 0x0
Jun  9 20:50:29 Andrews-MacBook-Pro.local java[959] <Error>: CGContextGetCTM: invalid context 0x0
Jun  9 20:50:29 Andrews-MacBook-Pro.local java[959] <Error>: CGContextSetBaseCTM: invalid context 0x0

这篇关于com.apple.eawt.Application 在混淆后不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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