Vision API出错

时间:2018-04-18 01:01:00

标签: android android-studio vision

我在Android Studio中的模拟器中运行一个应用程序时出现问题。

我建立了这个程序,没关系。但是,当我运行时出现此错误:

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)

我使用的是vision API Google。

我的build.gradle:

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'
}

第二个:

   // 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
}

在清单中添加元数据:

<?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>

主要的第38行:

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

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

有谁知道为什么在运行时发生此错误?

因为需要在模拟器中安装Vision API而发生?在这种情况下,如何在Android Studio的模拟器中安装Vision API?

0 个答案:

没有答案