There is method.
@Override
public boolean applicationContinueUserActivityRestorationHandler(UIApplication application, NSUserActivity userActivity, @ObjCBlock(name = "call_applicationContinueUserActivityRestorationHandler") Block_applicationContinueUserActivityRestorationHandler restorationHandler) {
NSURL url = userActivity != null ? userActivity.webpageURL() : null;
return doOpenUrl(url, fromApplication(application));
}
When it run, app crashed with error:
How can I avoid this?
kisg
(Gergely Kis - Migeran)
April 26, 2017, 4:52pm
2
Hi,
Can you provide us with a full project to reproduce this issue?
Best Regards,
Gergely
actually it crashes even when I just return true in applicationContinueUserActivityRestorationHandler method.
gistfile1.txt
*** Terminating app due to uncaught exception 'java.lang.RuntimeException', reason: 'java.lang.RuntimeException: Could not find Java method for native callback!
at org.moe.natj.objc.map.ObjCCallbackMapper.objectToJava(ObjCCallbackMapper.java:542)
at org.moe.natj.objc.map.ObjCCallbackMapper.toJava(ObjCCallbackMapper.java:630)
at org.moe.natj.general.NatJ.toJava(NatJ.java:1053)
at apple.uikit.c.UIKit.UIApplicationMain(Native Method)
at delightex.moe.MoeLauncher.main(MoeLauncher.java:281)
at delightex.moe.MoeLauncherRemote.main(MoeLauncherRemote.java:22)
'
*** First throw call stack:
(0x189b6d1b8 0x1885a455c 0x103e4eb78 0x103e5466c 0x103e78e38 0x103e641b4 0x18fc9fd0c 0x18ff533cc 0x18ff54144 0x19003c068 0x19003c3ac 0x18fc9f9f8 0x18ff53364 0x18ff53e84 0x104675258 0x104675218 0x10467a280 0x189b1a810 0x189b183fc 0x189a462b8 0x18b4fa198 0x18fa867fc 0x18fa81534 0x103e64044 0x103e786c0 0x103e56084 0x103e55f24 0x103e56fe8 0x103e78e38 0x103e641b4 0x109d56fb4 0x103b6edc0 0x103bb58c4 0x103bb5604 0x103c62954 0x103949fa8 0x103d05c4c 0x103948284 0x1000bd4a0 0x188a295b8)
This file has been truncated. show original
If I don’t overrite that method then no crash on opening url, but no useful business logic too.
Ok, I’ll try to provide you sample application.
Is there any workaround for it? Can I write some jni code to handle this selector?
class MoeLauncher extends NSObject implements UIApplicationDelegate {
@Selector("application:continueUserActivity:restorationHandler:")
public native boolean applicationContinueUserActivityRestorationHandler(UIApplication application, NSUserActivity userActivity, @ObjCBlock(name = "call_applicationContinueUserActivityRestorationHandler") Block_applicationContinueUserActivityRestorationHandler restorationHandler);
......
}
If I use “native”, then that method doesn’t invoked.
There is simple sample to reproduce this bug:
import apple.NSObject;
import apple.foundation.*;
import apple.uikit.*;
import apple.uikit.c.UIKit;
import apple.uikit.protocol.UIApplicationDelegate;
import org.moe.natj.general.Pointer;
import org.moe.natj.general.ann.RegisterOnStartup;
import org.moe.natj.objc.ann.Selector;
@RegisterOnStartup
public class Main extends NSObject implements UIApplicationDelegate {
public static void main(String[] args) {
UIKit.UIApplicationMain(0, null, null, Main.class.getName());
}
@Override
@Selector("application:didFinishLaunchingWithOptions:")
public boolean applicationDidFinishLaunchingWithOptions(UIApplication application, NSDictionary<?, ?> launchOptions) {
System.out.println("Hello");
UIWindow window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen().bounds());
window.setRootViewController(UIViewController.alloc().init());
window.makeKeyAndVisible();
return true;
}
@Override
public boolean applicationContinueUserActivityRestorationHandler(UIApplication application, NSUserActivity userActivity, Block_applicationContinueUserActivityRestorationHandler restorationHandler) {
return false;
}
protected Main(Pointer peer) {
super(peer);
}
}
you should also set correct provisioning profile and Entitlements.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:mysampl.es</string>
</array>
</dict>
</plist>
and open link mysampl.es. Then it crash:
kisg
(Gergely Kis - Migeran)
April 28, 2017, 9:52am
6
Hi,
thanks, we will take a look.
Best Regards,
Gergely
vighr
(Roland Vigh - Migeran)
April 28, 2017, 3:35pm
7
Hi,
@ObjCBlock (name = “call_applicationContinueUserActivityRestorationHandler”) annotation is missed in the method. Please add to method, see:
@Selector("application:continueUserActivity:restorationHandler:")
public boolean applicationContinueUserActivityRestorationHandler(UIApplication application,
NSUserActivity userActivity,
@ObjCBlock(name = "call_applicationContinueUserActivityRestorationHandler") Block_applicationContinueUserActivityRestorationHandler restorationHandler) {
return false;
}
Best Regards,
Roland
Same crash with that @ObjCBlock
no difference
vighr
(Roland Vigh - Migeran)
April 28, 2017, 3:51pm
9
My test project worked
ifaddrs.zip (77.3 KB)
kisg
(Gergely Kis - Migeran)
April 28, 2017, 4:08pm
10
Can you confirm that the annotation is still there after the retrolambda phase (build/moe/main/retro/output)?
Yes, annotation still here.
Your sample works. My sample doesn’t work.
I found where is problem - proguard. I use proguard ‘all’ with rules(moe-specific part is here):
#moe
-keep interface apple.uikit.protocol.UIApplicationDelegate { *; }
-keepclassmembers class ** {
@org.moe.natj.objc.ann.** public *;
}
Do you have recommended proguard rules? To avoid similar problems in future?
fixed it by add
-keepattributes RuntimeVisibleParameterAnnotations