Runtime Error

0

I have a problem running an application to capture text from an image.

I compile the program and it works fine, however, at the time of executing this error:

I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:0
E/TextNativeHandle: Error creating remote native handle
                    com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0.
                        at com.google.android.gms.dynamite.DynamiteModule.load(Unknown Source)
                        at com.google.android.gms.internal.vision.zzj.zzh(Unknown Source)
                        at com.google.android.gms.internal.vision.zzj.isOperational(Unknown Source)
                        at com.google.android.gms.vision.text.TextRecognizer.isOperational(Unknown Source)
                        at exemplo.capturartexto.MainActivity.getText(MainActivity.java:38)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                        at android.view.View.performClick(View.java:5637)
                        at android.view.View$PerformClick.run(View.java:22429)
                        at android.os.Handler.handleCallback(Handler.java:751)
                        at android.os.Handler.dispatchMessage(Handler.java:95)
                        at android.os.Looper.loop(Looper.java:154)
                        at android.app.ActivityThread.main(ActivityThread.java:6119)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

I'm using vision API of Google. To suck it you have to add it to build.gradle . It was as follows:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "exemplo.capturartexto"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    implementation 'com.google.android.gms:play-services-vision:15.0.0'
}

And the other became so:

   // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {

        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'


            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            google()
            jcenter()
            maven{
                url "https://maven.google.com"
            }
        }
    }

task clean(type: Delete) {
    delete rootProject.buildDir
}

You also have to add the meta-data in the manifest. It looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="exemplo.capturartexto">

    <uses-permission android:name="android.permission.INTERNET"
        ></uses-permission>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <meta-data android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="orc"></meta-data>

    </application>

</manifest>

And line 38 of main that the error references is:

TextRecognizer texto = new TextRecognizer.Builder(getApplicationContext()).build();

    if(!texto.isOperational()){
        Toast.makeText(getApplicationContext(), " Erro ao abrir",Toast.LENGTH_SHORT).show();
    }

Does anyone know why this error is occurring at runtime?

    
asked by anonymous 17.04.2018 / 21:16

0 answers