doc-rj / smartcard-reader

Android NFC contactless smart card reader
GNU General Public License v3.0
236 stars 96 forks source link

App crash #7

Closed bondhan closed 8 years ago

bondhan commented 8 years ago

Hi,

Thanks for the project, I just downloaded and give it a try on emulator and android device, on both the applications crashed, the error said null exception. Any ideas?

doc-rj commented 8 years ago

Hi, thanks for reporting. Could you provide a stack trace? Also, what mode were you using and what did you do exactly? Really, though, this app is intended to be used with physical devices, not Android emulators, since it depends on real NFC hardware and proximity to a second device's NFC antenna. Run the smartcard-reader app on a physical NFC-enabled android device on Kitkat or later. The second device can be a real NFC-enabled smartcard or a physical NFC-enabled smartphone or tablet with an app using HCE (smartcard emulation) -- for example, a wallet app (and the second device doesn't necessarily have to be an Android device). Make sense? It can be confusing, but I hope this helps. Of course, I haven't tested all configurations, platforms, etc, so there will be issues and crashes that need to be fixed. In any case, thanks again for the report and any further info you can provide.

bondhan commented 8 years ago

Hi, I tried on both and crashed. My phone is LG Optimus G Pro with lollipop. I do have experience in contactless smart card and basic of NFC. Would you like to tell how to solve this issue?


01-03 09:43:18.732 16808-16808/org.docrj.smartcard.reader E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: org.docrj.smartcard.reader, PID: 16808
                                                                            java.lang.RuntimeException: Unable to resume activity {org.docrj.smartcard.reader/org.docrj.smartcard.reader.AppSelectActivity}: java.lang.ClassCastException: com.afollestad.materialdialogs.MaterialDialog cannot be cast to android.app.AlertDialog
                                                                                at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2976)
                                                                                at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3007)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2373)
                                                                                at android.app.ActivityThread.access$800(ActivityThread.java:149)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
                                                                             Caused by: java.lang.ClassCastException: com.afollestad.materialdialogs.MaterialDialog cannot be cast to android.app.AlertDialog
                                                                                at org.docrj.smartcard.reader.NfcManager.onCreateDialog(NfcManager.java:111)
                                                                                at org.docrj.smartcard.reader.AppSelectActivity.onCreateDialog(AppSelectActivity.java:354)
                                                                                at android.app.Activity.onCreateDialog(Activity.java:3397)
                                                                                at android.app.Activity.createDialog(Activity.java:1102)
                                                                                at android.app.Activity.showDialog(Activity.java:3491)
                                                                                at android.app.Activity.showDialog(Activity.java:3449)
                                                                                at org.docrj.smartcard.reader.NfcManager.onResume(NfcManager.java:69)
                                                                                at org.docrj.smartcard.reader.AppSelectActivity.onResume(AppSelectActivity.java:307)
                                                                                at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1241)
                                                                                at android.app.Activity.performResume(Activity.java:6106)
                                                                                at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2965)
                                                                                at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3007) 
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2373) 
                                                                                at android.app.ActivityThread.access$800(ActivityThread.java:149) 
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                at android.os.Looper.loop(Looper.java:135) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5299) 
                                                                                at java.lang.reflect.Method.invoke(Native Method) 
                                                                                at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908) 
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703) 
01-03 09:43:27.881 16808-16808/? I/Process: Sending signal. PID: 16808 SIG: 9
doc-rj commented 8 years ago

Hi, this is fixed in today's commit: https://github.com/doc-rj/smartcard-reader/commit/8662bd7f91be0b9be17970160e0445d8c7724604

Can you check it and verify it works for you? Also, updated to compile against latest SDK and libs, so please clean your build. Thanks!

bondhan commented 8 years ago

It worked.Thanks. I will try to explore more.

doc-rj commented 8 years ago

Ok good. I just realized I'm going to target SDK 22 instead of 23, so I'll probably have another commit later today for that. I want to avoid (for now) doing runtime permissions for people with M-release devices. Anyhow, it shouldn't be an issue with Lollipop.