nvanbenschoten/motion

IllegalArgumentException on Samsung devices

darwind opened this issue · 1 comments

After upgrading to version 1.1.0 we're getting below error.

From what we can see it's only an issue on Samsung devices running Android 4.3 and especially on Samsung S4 and Samsung Note 3.

We can't reproduce it ourselves because of missing test devices, but the above is what Crashlytics tells us in the logs.

I've found this thread about SensorManager.getRotationMatrixFromVector throwing this IllegalArgumentException: https://groups.google.com/forum/#!topic/android-developers/U3N9eL5BcJk

This "quick-fix"/workaround is adding a try-catch to the part of the code, where SensorManager.getRotationMatrixFromVector is called and then change the length of array to 3, if this exception is thrown.

java.lang.IllegalArgumentException: R array length must be 3 or 4
at android.hardware.SensorManager.getRotationMatrixFromVector(SensorManager.java:1336)
at com.nvanbenschoten.motion.SensorInterpreter.setTargetVector(SensorInterpreter.java:134)
at com.nvanbenschoten.motion.SensorInterpreter.interpretSensorEvent(SensorInterpreter.java:74)
at com.nvanbenschoten.motion.ParallaxImageView.onSensorChanged(ParallaxImageView.java:119)
at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:463)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:132)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:5414)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(NativeStart.java)

Closing as a duplicate of #16