datalogic / android-samples-astudio

Sample apps for Datalogic Android SDK
9 stars 39 forks source link

DeviceSample API crash #8

Open rentzzz opened 5 years ago

rentzzz commented 5 years ago

Hi, The DeviceSampleAPI in particular the Battery activity is crashing already within the onCreate.

--------- beginning of crash 2019-08-27 14:26:54.980 26184-26184/com.datalogic.examples.devicesampleapi E/AndroidRuntime: FATAL EXCEPTION: main Process: com.datalogic.examples.devicesampleapi, PID: 26184 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.datalogic.examples.devicesampleapi/com.datalogic.examples.devicesampleapi.BatteryActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.datalogic.device.battery.DLBatteryManager.getIntProperty(com.datalogic.device.battery.BatteryInfo)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2805) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2883) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6523) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.datalogic.device.battery.DLBatteryManager.getIntProperty(com.datalogic.device.battery.BatteryInfo)' on a null object reference at com.datalogic.examples.devicesampleapi.BatteryActivity.getBatteryInfo(BatteryActivity.java:70) at com.datalogic.examples.devicesampleapi.BatteryActivity.setText(BatteryActivity.java:43) at com.datalogic.examples.devicesampleapi.BatteryActivity.onCreate(BatteryActivity.java:37) at android.app.Activity.performCreate(Activity.java:7023) at android.app.Activity.performCreate(Activity.java:7014) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2758) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2883)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6523)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)  2019-08-27 14:26:54.986 987-1307/? W/ActivityManager: Force finishing activity com.datalogic.examples.devicesampleapi/.BatteryActivity 2019-08-27 14:26:54.990 987-1307/? W/ActivityManager: Force finishing activity com.datalogic.examples.devicesampleapi/.DeviceAPITest

It seems that there is an issue around this line: DLBatteryManager deviceBattery = DLBatteryManager.getInstance();

Info:

My general goal is to accomplish to get additional BatteryInfo like CAPACITY_FULL, PRODUCTION_YEAR, SERIAL_NUMBER and so on. Thanks for any help.

KR

mpennasilico commented 5 years ago

Hi Mattias,

thank you for your reporting. Take into account that the version of Memor10 installed on your device could not support the Datalogic SDK v1.20 released on August. Please, could you share us the build number of sw version installed on your Memor10 Android 8 device? I will check which version of Datalogic SDK is support by your Memor10 device.

thank you, MP

rentzzz commented 5 years ago

Hi,

Thanks for quick reply. I'm sorry I mixed something. I'm using v1.20 within my application, the Datalogic DeviceSample APi is using 1.17.

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.github.datalogic:datalogic-android-sdk:1.17'
}

Thanks upfront.

mpennasilico commented 5 years ago

Thank you Mattias for the clarification. May you share with us the build number of sw version installed on your Memor10 Android 8 device? This is very important to allow us to check and address your issue.

Thanks, MP

rentzzz commented 5 years ago

Hi,

build number: 0.02.07.20180810 Datalogic services: 1.1.10.6 r3

KR Mattias

mpennasilico commented 5 years ago

Your device supports Datalogic SDK v1.08, as you can check from the Settings. But the features of com.datalogic.battery (reported by your error log) have been introduced by Datalogic SDK v1.13. So, you should update your device with a newer sw version, if you need to interface with new feature of Datalogic SDK.

MP