我正在尝试将功能添加到现有的 iOS libGDX 应用程序(使用 RoboVM),以便在按下 scene2d.ui 按钮时,显示一个 MFMailComposeViewController 弹出窗口,其中附加了一组预定义的 CSV 文件,这些文件存储在应用程序的 Library > local文件夹。这是我到目前为止的代码:
进口和成员:
import org.robovm.apple.foundation.*;
import org.robovm.apple.messageui.MFMailComposeResult;
import org.robovm.apple.messageui.MFMailComposeViewController;
import org.robovm.apple.messageui.MFMailComposeViewControllerDelegate;
import org.robovm.apple.uikit.*;
import org.robovm.objc.ObjCObject;
private UIWindow mailWindow;
private UIViewController mailViewController;
private MFMailComposeViewController mailPicker;
方法:
private void createMailWindow()
{
mailWindow = new UIWindow(UIScreen.getMainScreen().getBounds());
mailViewController = new UIViewController();
mailWindow.setRootViewController(mailViewController);
}
private void sendEmail(String fileName, String subject, String body)
{
mailPicker = new MFMailComposeViewController();
mailPicker.addStrongRef(mailWindow);
String path = NSBundle.getMainBundle().getResourcePath();
if (fileName != null)
{
path = path.substring(0, path.lastIndexOf('/')) + "/Library/local/" + fileName;
}
MFMailComposeViewControllerDelegate delegate = new MFMailComposeViewControllerDelegate()
{
public void mailComposeControllerDidFinish(MFMailComposeViewController controller, MFMailComposeResult result, NSError error)
{
controller.dismissViewController(true, null);
mailPicker.removeFromParentViewController();
mailPicker.removeStrongRef(mailWindow);
mailWindow.setHidden(true);
mailPicker = null;
}
@Override
public void didFinish(MFMailComposeViewController controller, MFMailComposeResult result, NSError error)
{
}
};
mailPicker.setMailComposeDelegate(delegate);
mailPicker.addStrongRef((ObjCObject) delegate);
if (fileName != null)
{
// attach CSVs here...
}
mailPicker.setSubject((subject != null ? subject : "Test Results"));
mailPicker.setMessageBody((body != null ? body : "Please find attached the latest results data."), false);
if (MFMailComposeViewController.canSendMail())
{
mailWindow.getRootViewController().presentViewController(mailPicker, true, null);
mailWindow.makeKeyAndVisible();
}
}
}
我有这段代码,并且 Eclipse 在我尝试构建之前不会标记任何问题,因此我收到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/robovm/rt/bro/NativeObject
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.mmu.cfa.DesktopMain.main(DesktopMain.java:26)
Caused by: java.lang.ClassNotFoundException: org.robovm.rt.bro.NativeObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 49 more
我已将 RoboVM Cocoa Touch 库和 RoboVM 运行时库添加到我的主项目的构建路径中。如果我删除这两种方法,我的项目将毫无错误地构建。我还需要设置其他东西来让它运行吗?