Null Pointer error while trying to parse the UUID of the device during bluetooth Advertisement

-1

I am making an app for conducting Bluetooth experiments but whenever I click on the button that starts the Bluetooth transmission using an Advertiser the app just returns to the home screen and gives an error

The error comes only when I add the lines .addServiceUuid( pUuid ).addServiceData( pUuid, "Data".getBytes( StandardCharsets.UTF_8 ) ) in the following block of code :

ParcelUuid pUuid = new ParcelUuid( UUID.fromString( getString( R.string.ble_uuid ) ) );
        AdvertiseData data = new AdvertiseData.Builder()
                .setIncludeDeviceName(true)
                .addServiceUuid( pUuid )
               .addServiceData(pUuid,"Data".getBytes(StandardCharsets.UTF_8))
                .build();

Logcat:

2020-06-23 17:55:41.448 16586-16586/? I/.beacondistanc: Late-enabling -Xcheck:jni
2020-06-23 17:55:41.470 16586-16586/? E/.beacondistanc: Unknown bits set in runtime_flags: 0x28000
2020-06-23 17:55:41.491 16586-16586/? E/PswFrameworkFactory:  Reflect exception getInstance: java.lang.ClassNotFoundException: com.oppo.common.PswFrameworkFactoryImpl
2020-06-23 17:55:41.617 16586-16586/? I/Perf: Connecting to perf service.
2020-06-23 17:55:41.640 16586-16626/? E/Perf: Fail to get file list com.example.beacondistance
2020-06-23 17:55:41.641 16586-16626/? E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-06-23 17:55:41.641 16586-16626/? E/Perf: Fail to get file list com.example.beacondistance
2020-06-23 17:55:41.641 16586-16626/? E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-06-23 17:55:41.796 16586-16586/? W/.beacondistanc: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2020-06-23 17:55:41.797 16586-16586/? W/.beacondistanc: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2020-06-23 17:55:41.850 16586-16586/? D/ColorViewRootUtil: initSwipState
2020-06-23 17:55:41.851 16586-16586/? D/ColorViewRootUtil: mScreenHeight 2340, mScreenWidth 1080
2020-06-23 17:55:41.853 16586-16586/? D/WindowManager: Add to mViews: DecorView@4c01a42[MainActivity], this = android.view.WindowManagerGlobal@ed77a53,pkg= com.example.beacondistance
2020-06-23 17:55:41.906 16586-16627/? I/AdrenoGLES: QUALCOMM build                   : 14e4b2d, I0e419467bc
    Build Date                       : 12/10/19
    OpenGL ES Shader Compiler Version: EV031.27.05.01
    Local Branch                     : 
    Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.8.8.R1.10.00.00.545.055
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
2020-06-23 17:55:41.906 16586-16627/? I/AdrenoGLES: Build Config                     : S P 8.0.11 AArch64
2020-06-23 17:55:41.909 16586-16627/? I/AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
2020-06-23 17:55:41.911 16586-16627/? W/AdrenoUtils: <ReadGpuID_from_sysfs:194>: Failed to open /sys/class/kgsl/kgsl-3d0/gpu_model
2020-06-23 17:55:41.911 16586-16627/? W/AdrenoUtils: <ReadGpuID:218>: Failed to read chip ID from gpu_model. Fallback to use the GSL path
2020-06-23 17:55:41.928 16586-16627/? W/Gralloc3: mapper 3.x is not supported

There is no error on building the app, the error occurs only when I click the button that starts the Bluetooth Advertisement.

java
android
android-studio
bluetooth-lowenergy
android-bluetooth
asked on Stack Overflow Jun 23, 2020 by Ravish Jha • edited Jun 23, 2020 by Ravish Jha

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0