TC75 - Power Key Management tutorial - Casting ProfileManager throws exception

S Stafleu Buitendag 2 years 11 months ago
1 0 0

Hello Zebra Developer Community
 
I am trying to run the Power Key Management Tutorial (http://techdocs.zebra.com/emdk-for-android/6-3/tutorial/tutMxPowerKeyMa…) on a TC75 upgraded from KitKat to Lollipop.
 
When debugging via Android Studio, all is well, everything seems to run as it should.
 
When running the application on the device, an exception is thrown as follows:
 

java.lang.ClassCastException: com.symbol.emdk.payment.PaymentManager cannot be cast to com.symbol.emdk.ProfileManager

E/AndroidRuntime( 4669):    at com.ptsi.myapplication.MainActivity.onOpened(MainActivity.java:63)

E/AndroidRuntime( 4669):    at com.symbol.emdk.EMDKServiceConnection.notifyonConnected(EMDKServiceConnection.java:124)

E/AndroidRuntime( 4669):    at com.symbol.emdk.EMDKServiceConnection.onServiceConnected(EMDKServiceConnection.java:104)

E/AndroidRuntime( 4669):    at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1208)

E/AndroidRuntime( 4669):    at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1225)

E/AndroidRuntime( 4669):    at android.os.Handler.handleCallback(Handler.java:739)

E/AndroidRuntime( 4669):    at android.os.Handler.dispatchMessage(Handler.java:95)

E/AndroidRuntime( 4669):    at android.os.Looper.loop(Looper.java:135)

E/AndroidRuntime( 4669):    at android.app.ActivityThread.main(ActivityThread.java:5254)

E/AndroidRuntime( 4669):    at java.lang.reflect.Method.invoke(Native Method)

E/AndroidRuntime( 4669):    at java.lang.reflect.Method.invoke(Method.java:372)

E/AndroidRuntime( 4669):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)

E/AndroidRuntime( 4669):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

 
 
The error corresponds to the location where the emdkManager is used to get a ProfileManager instance:
profileManager = (ProfileManager) emdkManager.getInstance(EMDKManager.FEATURE_TYPE.PROFILE); 
Has anyone run into this type of issue before?
Am I missing something glaringly obvious? I used the code as it is in the tutorial with no alterations except for the profile name.
 
Why would the EMDKManager return a PaymentManager when run without the debugger, but correctly return a ProfileManager when run using the debugger?
 
Any help will be immensely appreciated.
 
Kind regards
Stafleu Buitendag
 

java.lang.ClassCastException: com.symbol.emdk.payment.PaymentManager cannot be cast to com.symbol.emdk.ProfileManager

E/AndroidRuntime( 4669):    at com.ptsi.myapplication.MainActivity.onOpened(MainActivity.java:63)

E/AndroidRuntime( 4669):    at com.symbol.emdk.EMDKServiceConnection.notifyonConnected(EMDKServiceConnection.java:124)

E/AndroidRuntime( 4669):    at com.symbol.emdk.EMDKServiceConnection.onServiceConnected(EMDKServiceConnection.java:104)

E/AndroidRuntime( 4669):    at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1208)

E/AndroidRuntime( 4669):    at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1225)

E/AndroidRuntime( 4669):    at android.os.Handler.handleCallback(Handler.java:739)

E/AndroidRuntime( 4669):    at android.os.Handler.dispatchMessage(Handler.java:95)

E/AndroidRuntime( 4669):    at android.os.Looper.loop(Looper.java:135)

E/AndroidRuntime( 4669):    at android.app.ActivityThread.main(ActivityThread.java:5254)

E/AndroidRuntime( 4669):    at java.lang.reflect.Method.invoke(Native Method)

E/AndroidRuntime( 4669):    at java.lang.reflect.Method.invoke(Method.java:372)

E/AndroidRuntime( 4669):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)

E/AndroidRuntime( 4669):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

CONTACT
Can’t find what you’re looking for?