iOS accelerometer causing crash

77 views
Skip to first unread message

jam...@fastlaneinnovations.com

unread,
Jul 15, 2017, 2:20:09 AM7/15/17
to CodenameOne Discussions
I'm trying to use the Sensor CN1LIB to get accelerometer data. The app crashes on iOS if I instantiate the SensorsManager. I have the following code that is called by another class to do that, and I'm passing in 10000 for the seconds/sample parameter.

accelerometer = SensorsManager.getSensorsManager(SensorsManager.TYPE_ACCELEROMETER, sampleRateMicroSeconds);
       
if (accelerometer != null) {
            accelerometer
.registerListener(new SensorListener() {
               
public void onSensorChanged(long timeStamp, float x, float y, float z) {
                    updateValues
(timeStamp, x, y, z);
               
}
           
});

I got the sources, and built it on XCode, and this is the stack trace it's giving:

2017-07-14 22:58:14.472104-0700 RallyPacControl[2992:2474293] [DYMTLInitPlatform] platform initialization successful
2017-07-14 22:58:15.196843-0700 RallyPacControl[2992:2474069] libMobileGestalt MobileGestaltSupport.m:153: pid 2992 (RallyPacControl) does not have sandbox access for frZQaeyWLUvLjeuEK43hmg and IS NOT appropriately entitled
2017-07-14 22:58:15.197163-0700 RallyPacControl[2992:2474069] libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>)
2017-07-14 22:58:16.599170-0700 RallyPacControl[2992:2474312] -[CMMotionManager init:]: unrecognized selector sent to instance 0x1700039b0
2017-07-14 22:58:16.600580-0700 RallyPacControl[2992:2474312] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CMMotionManager init:]: unrecognized selector sent to instance 0x1700039b0'
*** First throw call stack:
(0x187852fe0 0x1862b4538 0x187859ef4 0x187856f54 0x187752d4c 0x100314714 0x100bc6a3c 0x100315d10 0x1003142a8 0x100311ffc 0x100943a60 0x1009af358 0x1009897f0 0x10098abcc 0x100a70194 0x100435874 0x100432fbc 0x1007c01a0 0x100a70194 0x100182d14 0x100a70194 0x100a8c524 0x100bca3a8 0x18691568c 0x18691559c 0x186912cb4)
libc++abi.dylib: terminating with uncaught exception of type NSException


Shai Almog

unread,
Jul 15, 2017, 3:02:25 AM7/15/17
to CodenameOne Discussions, jam...@fastlaneinnovations.com
Odd. I haven't touched that code myself so I don't really know. Looking at the code it seems pretty similar to this:
https://stackoverflow.com/questions/8529224/how-do-i-initialize-cmmotionmanager-globaly-to-be-used-by-different-classes

I'm assuming this line is failing? https://github.com/chen-fishbein/sensors-codenameone/blob/master/CN1Sensors/native/ios/com_codename1_sensors_SensorsNativeImpl.m#L12

Are you using xcode 7.x or a newer version?
Please try with xcode 7.3.

If this isn't working the completion in xcode should suggest alternatives, if you can fix the code you can just edit it directly in the sensors github project and submit a pull request.

jam...@fastlaneinnovations.com

unread,
Jul 15, 2017, 4:06:31 AM7/15/17
to CodenameOne Discussions, jam...@fastlaneinnovations.com

I've got XCode 8.3.3. I'm wondering if they changed the methods. I'm terrible with Objective-C, but I'm looking through the Apple docs.

Shai Almog

unread,
Jul 16, 2017, 12:49:52 AM7/16/17
to CodenameOne Discussions, jam...@fastlaneinnovations.com
You can download 7.3 from the Apple website. I suggest using that for now

Fast Lane Innovations

unread,
Jul 17, 2017, 2:38:06 AM7/17/17
to codenameone...@googlegroups.com
I installed 7.3, but it's the same. I found that the problem is related to setting the sampling rate. If I don't set a rate, it works but I want to set a fast rate. I see that sampling rate is defined as an int, but the Apple docs mention sampling rate being an NSTimeInterval double. Their documentation is very sparse, so it's not clear how everything needs to be written. 


Best regards,
James Hastings
Fast Lane Innovations, LLC

On Jul 15, 2017, at 9:49 PM, Shai Almog <shai....@gmail.com> wrote:

You can download 7.3 from the Apple website. I suggest using that for now

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/zPiqtoeqe9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/25ad0705-0fa1-4309-9664-29a4c1f9c6ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shai Almog

unread,
Jul 18, 2017, 12:13:58 AM7/18/17
to CodenameOne Discussions, jam...@fastlaneinnovations.com
I think NSTimeInterval is seconds to the left of the dot and fractions of seconds to the right. Not sure  though.
Reply all
Reply to author
Forward
0 new messages