如何编译Google Vision API库?

时间:2018-03-20 13:58:50

标签: android android-library

我正在尝试实施Google Vision API,但在添加库后,我收到以下错误:

错误:任务执行失败':app:transformClassesWithMultidexlistForDebug'。

  

java.io.IOException:无法写入[/Users/anshul/AndroidStudioProjects/CisiveDemo/app/build/intermediates/multi-dex/debug/componentClasses.jar](无法读取[/ Users / anshul / .gradle / caches / modules-2 / files-2.1 / com.google.guava / guava-jdk5 / 17.0 / 463f8378feba44df7ba7cd9272d01837dad62b36 / guava-jdk5-17.0.jar(;;;;;; **。class)](重复邮编条目[guava-jdk5-17.0.jar:com / google / common / annotations / Beta.class]))

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.demo.cisive"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
    implementation 'com.basgeekball:awesome-validation:1.3'
    implementation 'com.google.android.gms:play-services-auth:11.8.0'
    implementation 'com.google.android.gms:play-services-base:11.8.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'


    implementation 'com.google.api-client:google-api-client-android:1.23.0'
    implementation 'com.google.http-client:google-http-client-gson:1.23.0'
    implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0'
}

依赖

+--- com.android.support:appcompat-v7:27.1.0
|    +--- com.android.support:support-annotations:27.1.0
|    +--- com.android.support:support-core-utils:27.1.0
|    |    +--- com.android.support:support-annotations:27.1.0
|    |    \--- com.android.support:support-compat:27.1.0
|    |         +--- com.android.support:support-annotations:27.1.0
|    |         \--- android.arch.lifecycle:runtime:1.1.0
|    |              +--- android.arch.lifecycle:common:1.1.0
|    |              \--- android.arch.core:common:1.1.0
|    +--- com.android.support:support-fragment:27.1.0
|    |    +--- com.android.support:support-compat:27.1.0 (*)
|    |    +--- com.android.support:support-core-ui:27.1.0
|    |    |    +--- com.android.support:support-annotations:27.1.0
|    |    |    +--- com.android.support:support-compat:27.1.0 (*)
|    |    |    \--- com.android.support:support-core-utils:27.1.0 (*)
|    |    +--- com.android.support:support-core-utils:27.1.0 (*)
|    |    +--- com.android.support:support-annotations:27.1.0
|    |    +--- android.arch.lifecycle:livedata-core:1.1.0
|    |    |    +--- android.arch.lifecycle:common:1.1.0
|    |    |    +--- android.arch.core:common:1.1.0
|    |    |    \--- android.arch.core:runtime:1.1.0
|    |    |         \--- android.arch.core:common:1.1.0
|    |    \--- android.arch.lifecycle:viewmodel:1.1.0
|    +--- com.android.support:support-vector-drawable:27.1.0
|    |    +--- com.android.support:support-annotations:27.1.0
|    |    \--- com.android.support:support-compat:27.1.0 (*)
|    \--- com.android.support:animated-vector-drawable:27.1.0
|         +--- com.android.support:support-vector-drawable:27.1.0 (*)
|         \--- com.android.support:support-core-ui:27.1.0 (*)
+--- com.android.support.constraint:constraint-layout:1.0.2
|    \--- com.android.support.constraint:constraint-layout-solver:1.0.2
+--- com.android.support:design:27.1.0
|    +--- com.android.support:support-v4:27.1.0
|    |    +--- com.android.support:support-compat:27.1.0 (*)
|    |    +--- com.android.support:support-media-compat:27.1.0
|    |    |    +--- com.android.support:support-annotations:27.1.0
|    |    |    \--- com.android.support:support-compat:27.1.0 (*)
|    |    +--- com.android.support:support-core-utils:27.1.0 (*)
|    |    +--- com.android.support:support-core-ui:27.1.0 (*)
|    |    \--- com.android.support:support-fragment:27.1.0 (*)
|    +--- com.android.support:appcompat-v7:27.1.0 (*)
|    +--- com.android.support:recyclerview-v7:27.1.0
|    |    +--- com.android.support:support-annotations:27.1.0
|    |    +--- com.android.support:support-compat:27.1.0 (*)
|    |    \--- com.android.support:support-core-ui:27.1.0 (*)
|    \--- com.android.support:transition:27.1.0
|         +--- com.android.support:support-annotations:27.1.0
|         \--- com.android.support:support-compat:27.1.0 (*)
+--- com.github.delight-im:Android-AdvancedWebView:v3.0.0
+--- com.basgeekball:awesome-validation:1.3
|    \--- com.google.guava:guava:19.0
+--- com.google.android.gms:play-services-auth:11.8.0
|    +--- com.google.android.gms:play-services-auth-api-phone:11.8.0
|    |    +--- com.google.android.gms:play-services-base:11.8.0
|    |    |    +--- com.google.android.gms:play-services-basement:11.8.0
|    |    |    |    +--- com.android.support:support-v4:25.2.0 -> 27.1.0 (*)
|    |    |    |    \--- com.google.android.gms:play-services-basement-license:11.8.0
|    |    |    +--- com.google.android.gms:play-services-tasks:11.8.0
|    |    |    |    +--- com.google.android.gms:play-services-basement:11.8.0 (*)
|    |    |    |    \--- com.google.android.gms:play-services-tasks-license:11.8.0
|    |    |    \--- com.google.android.gms:play-services-base-license:11.8.0
|    |    +--- com.google.android.gms:play-services-basement:11.8.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:11.8.0 (*)
|    |    \--- com.google.android.gms:play-services-auth-api-phone-license:11.8.0
|    +--- com.google.android.gms:play-services-auth-base:11.8.0
|    |    +--- com.google.android.gms:play-services-base:11.8.0 (*)
|    |    +--- com.google.android.gms:play-services-basement:11.8.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:11.8.0 (*)
|    |    \--- com.google.android.gms:play-services-auth-base-license:11.8.0
|    +--- com.google.android.gms:play-services-base:11.8.0 (*)
|    +--- com.google.android.gms:play-services-basement:11.8.0 (*)
|    \--- com.google.android.gms:play-services-tasks:11.8.0 (*)
+--- com.google.android.gms:play-services-base:11.8.0 (*)
+--- com.google.api-client:google-api-client-android:1.23.0
|    +--- com.google.api-client:google-api-client:1.23.0
|    |    +--- com.google.oauth-client:google-oauth-client:1.23.0
|    |    |    +--- com.google.http-client:google-http-client:1.23.0
|    |    |    |    +--- com.google.code.findbugs:jsr305:1.3.9
|    |    |    |    \--- org.apache.httpcomponents:httpclient:4.0.1
|    |    |    |         +--- org.apache.httpcomponents:httpcore:4.0.1
|    |    |    |         +--- commons-logging:commons-logging:1.1.1
|    |    |    |         \--- commons-codec:commons-codec:1.3
|    |    |    \--- com.google.code.findbugs:jsr305:1.3.9
|    |    +--- com.google.http-client:google-http-client-jackson2:1.23.0
|    |    |    +--- com.google.http-client:google-http-client:1.23.0 (*)
|    |    |    \--- com.fasterxml.jackson.core:jackson-core:2.1.3
|    |    \--- com.google.guava:guava-jdk5:17.0
|    \--- com.google.http-client:google-http-client-android:1.23.0
|         \--- com.google.http-client:google-http-client:1.23.0 (*)
+--- com.google.http-client:google-http-client-gson:1.23.0
|    +--- com.google.http-client:google-http-client:1.23.0 (*)
|    \--- com.google.code.gson:gson:2.1
+--- com.google.apis:google-api-services-vision:v1-rev369-1.23.0
|    \--- com.google.api-client:google-api-client:1.23.0 (*)
\--- com.android.support:multidex:1.0.2

1 个答案:

答案 0 :(得分:1)

这些线是问题(嗯,只是第一个,但其余的是相关的)。

implementation 'com.google.api-client:google-api-client-android:1.23.0'
implementation 'com.google.http-client:google-http-client-gson:1.23.0'
implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0'

如果搜索依赖项的输出,则会在错误中看到库。 com.google.guava:guava-jdk5:17.0 ... Android最初支持JDK6,所以即使拥有一个JDK5库也是一个错误的标志。

google-api-java-client项目处于维护模式,不是推荐用于Android开发的库。

请改用Google Play Services APIs。 (您已经在使用Auth)。例如,那里有一个Vision API。

如果您需要支持Gson的HTTP客户端,请结帐Retrofit