Hello @all,
I'm trying to get motion information out of the CMMotionActivitiyManager API, but for some reasons every time I start the ActivityUpdates (Method call: motionManager.StartActivityUpdates(...)) the App Crashes with the following information:
critical:
Native stacktrace:
2017-06-22 10:39:04.793 MomentDrive.iOS[1055:187393] critical: 0 MomentDrive.iOS 0x0000000101613de4 mono_handle_native_crash + 260
2017-06-22 10:39:04.793 MomentDrive.iOS[1055:187393] critical: 1 libsystem_platform.dylib 0x000000018ad1131c _sigtramp + 52
2017-06-22 10:39:04.793 MomentDrive.iOS[1055:187393] critical: 2 libsystem_kernel.dylib 0x000000018ac484d0 + 100
2017-06-22 10:39:04.793 MomentDrive.iOS[1055:187393] critical: 3 libsystem_kernel.dylib 0x000000018ac484fc system_set_sfi_window + 0
2017-06-22 10:39:04.793 MomentDrive.iOS[1055:187393] critical: 4 TCC 0x000000018de64498 + 0
2017-06-22 10:39:04.793 MomentDrive.iOS[1055:187393] critical: 5 TCC 0x000000018de643b8 + 0
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 6 TCC 0x000000018de673d4 + 340
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 7 libxpc.dylib 0x000000018ad46f38 + 80
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 8 libxpc.dylib 0x000000018ad46ea8 + 40
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 9 libdispatch.dylib 0x000000018ab0a9a0 + 16
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 10 libdispatch.dylib 0x000000018ab190d4 + 644
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393
] critical: 11 libdispatch.dylib 0x000000018ab1aa50 + 540
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 12 libdispatch.dylib 0x000000018ab1a7d0 + 124
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 13 libsystem_pthread.dylib 0x000000018ad13100 _pthread_wqthread + 1096
2017-06-22 10:39:04.794 MomentDrive.iOS[1055:187393] critical: 14 libsystem_pthread.dylib 0x000000018ad12cac start_wqthread + 4
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
The code looks like this:
if (CMMotionActivityManager.IsActivityAvailable) { var motionManager = new CMMotionActivityManager(); var queue = new NSOperationQueue(); motionManager.StartActivityUpdates(queue, action => { if (action.Automotive) { } }); }
I have fixed this. The problem was that I needed to set the correct key in the info.plist. If you see CoreMotion docs:
Important An iOS app linked on or after iOS 10.0 must include usage description keys in its Info.plist file for the types of data it needs. Failure to include these keys will cause the app to crash. To access motion and fitness data specifically, it must include NSMotionUsageDescription.
So you need to include something like this in info.plist:
<key>NSMotionUsageDescription</key> <string>MotionActivity App needs Motion Access</string>
Answers
I'm getting the same error, with the same code as you.
2017-07-01 11:38:51.722 iosapp[1095:318780] critical:
Native stacktrace:
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 0 libmonosgen-2.0.dylib 0x00000001007d5920 mono_handle_native_crash + 260
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 1 libsystem_platform.dylib 0x000000018ca1131c _sigtramp + 52
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 2 libsystem_kernel.dylib 0x000000018c9484d0 + 100
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 3 libsystem_kernel.dylib 0x000000018c9484fc system_set_sfi_window + 0
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 4 TCC 0x000000018fb64498 + 0
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 5 TCC 0x000000018fb643b8 + 0
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 6 TCC 0x000000018fb673d4 + 340
2017-07-01 11:38:51.813 iosapp[1095:318780] critical: 7 libxpc.dylib 0x000000018ca46f38 + 80
2017-07-01 11:38:51.814 iosapp[1095:318780] critical: 8 libxpc.dylib 0x000000018ca46ea8 + 40
2017-07-01 11:38:51.814 iosapp[1095:318780] critical: 9 libdispatch.dylib 0x000000018c80a9a0 + 16
2017-07-01 11:38:51.814 iosapp[1095:318780] critical: 10 libdispatch.dylib 0x000000018c8190d4 + 644
2017-07-01 11:38:51.814 iosapp[1095:318780] critical: 11 libdispatch.dylib 0x000000018c81aa50 + 540
2017-07-01 11:38:51.814 iosapp[1095:318780] critical: 12 libdispatch.dylib 0x000000018c81a7d0 + 124
2017-07-01 11:38:51.814 iosapp[1095:318780] critical: 13 libsystem_pthread.dylib 0x000000018ca13100 _pthread_wqthread + 1096
2017-07-01 11:38:51.814 iosapp[1095:318780] critical: 14 libsystem_pthread.dylib 0x000000018ca12cac start_wqthread + 4
2017-07-01 11:38:51.814 iosapp[1095:318780] critical:
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
I have fixed this. The problem was that I needed to set the correct key in the info.plist. If you see CoreMotion docs:
So you need to include something like this in info.plist:
@ChristianPolanc @tura08 do either of you have a sample of this Xamarin iOS project you could share? I have been tasked with figuring out motion for company app to see if someone is driving a vehicle. Much appreciated, thanks.