Tenho um problema na hora de executar uma aplicação para capturar textos vindo de uma imagem.
Eu compilo o programa e dá tudo certo, contudo na hora de executar da esse erro :
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)
Estou usando a vision API
do Google. Para suá-la tem que adicioná-la ao build.gradle
. Ficou da seguinte forma :
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'
}
E o outro ficou ssim :
// 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
}
Também tem que adicionar o meta-data no manifest. Ficou assim :
<?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>
E a linha 38 da main que o erro faz referência é :
TextRecognizer texto = new TextRecognizer.Builder(getApplicationContext()).build();
if(!texto.isOperational()){
Toast.makeText(getApplicationContext(), " Erro ao abrir",Toast.LENGTH_SHORT).show();
}
Alguém sabe por que está ocorrendo esse erro na hora de execução ?