BlinkReceipt / blinkreceipt-android

MIT License
49 stars 16 forks source link

Error while launching the camera ui on android #68

Closed vtn-dev-manish closed 1 year ago

vtn-dev-manish commented 1 year ago

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gfk.consumerscan/com.microblink.camera.ui.CameraScanActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at com.microblink.camera.ui.CameraScanActivity.onCreate(line:62) at android.app.Activity.performCreate(Activity.java:7994) at android.app.Activity.performCreate(Activity.java:7978) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)

Code:

val launcher: ActivityResultLauncher<CameraRecognizerOptions> =
            registerForActivityResult(CameraRecognizerContract()) { result ->
            }
    findViewById<Button>(R.id.start_blink).setOnClickListener {
        launcher.launch(CameraRecognizerOptions.Builder().build())
    }