text:
Q: Canny Edge Detection (Android OpenCV) app unfortunately stops @Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    if (id == R.id.Canny_Edge) //Unfortunately stops the app when we use this option    {
        ImageView i = (ImageView) findViewById(R.id.image_view);

        Bitmap bmp =BitmapFactory.decodeResource(getResources(),R.drawable.smiley);
        Mat srcMat = new Mat ( bmp.getHeight(), bmp.getWidth(), CvType.CV_8UC3);

        Bitmap myBitmap32 = bmp.copy(Bitmap.Config.ARGB_8888, true);

        Utils.bitmapToMat(myBitmap32, srcMat);

        Mat gray = new Mat(srcMat.size(), CvType.CV_8UC1);
        Imgproc.cvtColor(srcMat, gray, Imgproc.COLOR_RGB2GRAY,4);
        Mat edge = new Mat();
        Mat dst = new Mat();
        Imgproc.Canny(gray, edge, 80, 90);
        Imgproc.cvtColor(edge, dst, Imgproc.COLOR_GRAY2RGBA,4);
        Bitmap resultBitmap = Bitmap.createBitmap(dst.cols(), dst.rows(),Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(dst, resultBitmap);

        i.setImageBitmap(resultBitmap);
    }
    else if(id == R.id.Sobel) {
        ImageView i = (ImageView) findViewById(R.id.image_view);
        i.setImageResource(R.drawable.apj);
           //some code
    }

    return super.onOptionsItemSelected(item);
}

In the above code ,Android studio doesn't shows any errors .
But the app unfortunately stops on getting this Canny_Edge option(in the menu).
Why, Can anyone solve this problem.

A: I have answered a similar question on: https://stackoverflow.com/a/50637228/1693327 but I am unable to comment to the post due to lack of reputation points so I will copy the answer below.
The device should be crashing when it executes the Imgproc.Canny function call.
I believe the app is crashing when it hits the Canny detector because of the wrong type of OpenCV Manager installed on your device, be it version number or central processor instruction set. Checking the correct version should be straightforward. Just go to the OpenCV-android-sdk\apk directory and check for the 3 (x.y.z) numbers after OpenCV_
Checking instruction set of Android devices for Windows
To check the instruction set of your device, navigate to the adb (android debug bridge) directory commonly located at:
C:\Users\<'your username'>\AppData\Local\Android\Sdk\platform-tools
Run the command:
./adb.exe shell cat /proc/cpuinfo

After getting the correct instruction set, navigate back to the OpenCV-android-sdk\apk and locate the correct apk version and instruction set to be installed on your android device.
You can then transfer the apk to your device and install it. Another way I find useful is to navigate to the adb.exe directory and run the command:
./adb.exe install <path to OpenCV-android-sdk>/apk/OpenCV_x.y.z_Manager_x.yz_<platform instruction set>.apk

Apart from the steps above, make sure that you do not have any other environment variables that use other types of OpenCV Manager such as stating a different one in the Application.mk or build.gradle files.
After the steps above, your Canny detector should be able to run on your device without crashing.
Happy Developing :).