TextRecognizer isOperational API always returns fa

2019-08-03 07:39发布

问题:

I need to capture characters of an image so i am using TextRecognizer. My code is given below

TextRecognizer textRecognizer = new TextRecognizer.Builder(mActivity.getGalleryApplication().getAndroidContext()).build();
if (!textRecognizer.isOperational()) {
    new AlertDialog.Builder(mActivity.getAndroidContext())
                                        .setMessage("Text recognizer could not be set up :(").show();
    return;
}
textRecognizer.release();

I have added dependencies in build.gradle as below:

    dependencies {
        compile 'com.google.android.gms:play-services-maps:10.2.1'
        compile 'com.google.firebase:firebase-appindexing:10.2.1'
        compile 'com.android.support:appcompat-v7:23.0.0'       
    }

Everytime I launch the apk, "Text recognizer could not be set up : is displayed. Even though I have set all dependencies but still i am getting this error. Please help why TextRecognizer.isOperational() is always false.

I have a project to be completed by next weekend. Please help to solve this error.

回答1:

I found answer to my question.

We need to apply the below commands in command prompt. Then issue is resolved.

adb root
adb remount
adb shell setenforce 0  it will disable SE policy 
adb remount