Как обновить внешнюю библиотеку в банке в Android Studio

Я новичок в Android Studio и Google-Cloud API. Я хотел бы использовать Google-Cloud-Speech с Google-API-клиента, чтобы использовать OAUT. Но теперь я изо всех сил пытался построить свой код; может возникнуть проблема с дублированием имени библиотеки.

Чтобы восстановить ошибку сборки, я создаю новый проект и просто помещаю следующие зависимости и packageOptions в build.gradle (Module:app). Он может собираться без android (виртуального) устройства, но его не удалось собрать с android (виртуальным) устройством; другими словами, он может быть построен с помощью (Build Menu) -> (Clean Project), но не может быть выполнен с помощью (Run Menu) -> (Debug).

android {
    compileSdkVersion 26
    ...

    packagingOptions {
        exclude 'project.properties'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    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'

    annotationProcessor 'com.google.cloud:google-cloud-speech:0.32.0-alpha'
    implementation 'com.google.cloud:google-cloud-speech:0.32.0-alpha'

    implementation 'com.google.api-client:google-api-client:1.23.0'

}

Сообщение об ошибке следующее,

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Я погуглил ошибку "app:transformDexArchiveWithExternalLibsDexMergerForDebug" и полагаю, что она связана с дублированием имен библиотек.

Поэтому я проверил дерево зависимостей с помощью следующей команды в командной строке.

$> gradlew app:dependencies 

И я обнаружил несоответствие версии библиотеки 'com.google.http-client:google-http-client-jackson2'. Одна из ее версий - 1.19.0, но все остальные версии - 1.23.0. (Пожалуйста, посмотрите, чтобы проверить копию вывода приложения gradlew: зависимости в конце этого поста.)

Я хотел бы знать, как обновить библиотеку во внешней банке. Пожалуйста, дайте мне знать это.

Часть вывода "gradlew app: зависимости"

debugAndroidTestRuntimeClasspath - Resolved configuration for runtime for variant: debugAndroidTest
+--- 
|   +--- com.android.support:support-annotations:25.4.0 -> 26.1.0
|    +--- junit:junit:4.12
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    \--- net.sf.kxml:kxml2:2.3.0
+--- com.android.support.test.espresso:espresso-core:3.0.1
|    +--- 
|    +--- com.android.support.test:rules:1.0.1
|    |    \--- 
|    +--- com.android.support.test.espresso:espresso-idling-resource:3.0.1
|    +--- com.squareup:javawriter:2.1.1
|    +--- javax.inject:javax.inject:1
|    +--- org.hamcrest:hamcrest-library:1.3
|    |    \--- org.hamcrest:hamcrest-core:1.3
|    +--- org.hamcrest:hamcrest-integration:1.3
|    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
|    \--- com.google.code.findbugs:jsr305:2.0.1 -> 3.0.0
+--- com.android.support:multidex-instrumentation:1.0.2
|    \--- com.android.support:multidex:1.0.2
+--- com.android.support:appcompat-v7:26.1.0
|    +--- com.android.support:support-annotations:26.1.0
|    +--- com.android.support:support-v4:26.1.0
|    |    +--- com.android.support:support-compat:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- android.arch.lifecycle:runtime:1.0.0
|    |    |         +--- android.arch.lifecycle:common:1.0.0
|    |    |         \--- android.arch.core:common:1.0.0
|    |    +--- com.android.support:support-media-compat:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- com.android.support:support-compat:26.1.0 (*)
|    |    +--- com.android.support:support-core-utils:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- com.android.support:support-compat:26.1.0 (*)
|    |    +--- com.android.support:support-core-ui:26.1.0
|    |    |    +--- com.android.support:support-annotations:26.1.0
|    |    |    \--- com.android.support:support-compat:26.1.0 (*)
|    |    \--- com.android.support:support-fragment:26.1.0
|    |         +--- com.android.support:support-compat:26.1.0 (*)
|    |         +--- com.android.support:support-core-ui:26.1.0 (*)
|    |         \--- com.android.support:support-core-utils:26.1.0 (*)
|    +--- com.android.support:support-vector-drawable:26.1.0
|    |    +--- com.android.support:support-annotations:26.1.0
|    |    \--- com.android.support:support-compat:26.1.0 (*)
|    \--- com.android.support:animated-vector-drawable:26.1.0
|         +--- com.android.support:support-vector-drawable:26.1.0 (*)
|         \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.android.support.constraint:constraint-layout:1.0.2
|    \--- com.android.support.constraint:constraint-layout-solver:1.0.2
+--- com.google.cloud:google-cloud-speech:0.32.0-alpha
|    +--- io.netty:netty-tcnative-boringssl-static:2.0.6.Final
|    +--- com.google.cloud:google-cloud-core:1.14.0
|    |    +--- com.google.guava:guava:20.0
|    |    +--- joda-time:joda-time:2.9.2
|    |    +--- org.json:json:20160810
|    |    +--- com.google.http-client:google-http-client:1.23.0
|    |    |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.0
|    |    |    \--- 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:3.0.0
|    |    +--- com.google.api:api-common:1.2.0
|    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
|    |    |    \--- com.google.guava:guava:19.0 -> 20.0
|    |    +--- com.google.api:gax:1.15.0
|    |    |    +--- com.google.auto.value:auto-value:1.2
|    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
|    |    |    +--- com.google.guava:guava:20.0
|    |    |    +--- org.threeten:threetenbp:1.3.3
|    |    |    +--- com.google.auth:google-auth-library-oauth2-http:0.9.0
|    |    |    |    +--- com.google.auth:google-auth-library-credentials:0.9.0
|    |    |    |    +--- com.google.http-client:google-http-client:1.19.0 -> 1.23.0 (*)
|    |    |    |    +--- com.google.http-client:google-http-client-jackson2:1.19.0 -> 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:19.0 -> 20.0
|    |    |    \--- com.google.api:api-common:1.2.0 (*)
|    |    +--- com.google.protobuf:protobuf-java-util:3.4.0
|    |    |    +--- com.google.protobuf:protobuf-java:3.4.0
|    |    |    +--- com.google.guava:guava:19.0 -> 20.0
|    |    |    \--- com.google.code.gson:gson:2.7
|    |    +--- com.google.api.grpc:proto-google-common-protos:1.0.2
|    |    |    \--- com.google.protobuf:protobuf-java:3.4.0
|    |    \--- com.google.api.grpc:proto-google-iam-v1:0.1.26
|    |         +--- com.google.protobuf:protobuf-java:3.3.0 -> 3.4.0
|    |         +--- com.google.api.grpc:proto-google-common-protos:1.0.2 (*)
|    |         \--- com.google.api:api-common:1.1.0 -> 1.2.0 (*)
|    +--- com.google.cloud:google-cloud-core-grpc:1.14.0
|    |    +--- io.netty:netty-tcnative-boringssl-static:2.0.6.Final
|    |    +--- com.google.auth:google-auth-library-credentials:0.9.0
|    |    +--- com.google.cloud:google-cloud-core:1.14.0 (*)
|    |    +--- com.google.guava:guava:20.0
|    |    +--- com.google.protobuf:protobuf-java:3.4.0
|    |    +--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
|    |    +--- io.grpc:grpc-protobuf:1.7.0
|    |    |    +--- io.grpc:grpc-core:1.7.0
|    |    |    |    +--- io.grpc:grpc-context:1.7.0
|    |    |    |    +--- com.google.guava:guava:19.0 -> 20.0
|    |    |    |    +--- com.google.errorprone:error_prone_annotations:2.0.19
|    |    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
|    |    |    |    +--- com.google.instrumentation:instrumentation-api:0.4.3
|    |    |    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
|    |    |    |    |    \--- com.google.guava:guava:19.0 -> 20.0
|    |    |    |    \--- io.opencensus:opencensus-api:0.6.0
|    |    |    |         \--- com.google.guava:guava:19.0 -> 20.0
|    |    |    +--- com.google.protobuf:protobuf-java:3.4.0
|    |    |    +--- com.google.guava:guava:19.0 -> 20.0
|    |    |    +--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
|    |    |    +--- com.google.api.grpc:proto-google-common-protos:0.1.9 -> 1.0.2 (*)
|    |    |    \--- io.grpc:grpc-protobuf-lite:1.7.0
|    |    |         +--- io.grpc:grpc-core:1.7.0 (*)
|    |    |         \--- com.google.guava:guava:19.0 -> 20.0
|    |    +--- io.grpc:grpc-context:1.7.0
|    |    +--- io.grpc:grpc-netty:1.7.0
|    |    |    +--- io.grpc:grpc-core:[1.7.0] -> 1.7.0 (*)
|    |    |    +--- io.netty:netty-codec-http2:[4.1.16.Final] -> 4.1.16.Final
|    |    |    |    +--- io.netty:netty-codec-http:4.1.16.Final
|    |    |    |    |    \--- io.netty:netty-codec:4.1.16.Final
|    |    |    |    |         \--- io.netty:netty-transport:4.1.16.Final
|    |    |    |    |              +--- io.netty:netty-buffer:4.1.16.Final
|    |    |    |    |              |    \--- io.netty:netty-common:4.1.16.Final
|    |    |    |    |              \--- io.netty:netty-resolver:4.1.16.Final
|    |    |    |    |                   \--- io.netty:netty-common:4.1.16.Final
|    |    |    |    \--- io.netty:netty-handler:4.1.16.Final
|    |    |    |         +--- io.netty:netty-buffer:4.1.16.Final (*)
|    |    |    |         +--- io.netty:netty-transport:4.1.16.Final (*)
|    |    |    |         \--- io.netty:netty-codec:4.1.16.Final (*)
|    |    |    \--- io.netty:netty-handler-proxy:4.1.16.Final
|    |    |         +--- io.netty:netty-transport:4.1.16.Final (*)
|    |    |         +--- io.netty:netty-codec-socks:4.1.16.Final
|    |    |         |    \--- io.netty:netty-codec:4.1.16.Final (*)
|    |    |         \--- io.netty:netty-codec-http:4.1.16.Final (*)
|    |    +--- io.grpc:grpc-stub:1.7.0
|    |    |    \--- io.grpc:grpc-core:1.7.0 (*)
|    |    +--- io.grpc:grpc-auth:1.7.0
|    |    |    +--- io.grpc:grpc-core:[1.7.0] -> 1.7.0 (*)
|    |    |    \--- com.google.auth:google-auth-library-credentials:0.4.0 -> 0.9.0
|    |    \--- com.google.api:gax-grpc:1.15.0
|    |         +--- com.google.auto.value:auto-value:1.2
|    |         +--- com.google.code.findbugs:jsr305:3.0.0
|    |         +--- com.google.api:gax:1.15.0 (*)
|    |         +--- io.grpc:grpc-netty:1.7.0 (*)
|    |         +--- io.grpc:grpc-stub:1.7.0 (*)
|    |         +--- io.grpc:grpc-auth:1.7.0 (*)
|    |         +--- io.grpc:grpc-protobuf:1.7.0 (*)
|    |         +--- com.google.guava:guava:20.0
|    |         +--- org.threeten:threetenbp:1.3.3
|    |         +--- com.google.auth:google-auth-library-oauth2-http:0.9.0 (*)
|    |         +--- com.google.auth:google-auth-library-credentials:0.9.0
|    |         +--- com.google.api.grpc:proto-google-common-protos:1.0.0 -> 1.0.2 (*)
|    |         \--- com.google.api:api-common:1.2.0 (*)
|    +--- com.google.api.grpc:proto-google-cloud-speech-v1beta1:0.1.26
|    |    +--- com.google.api.grpc:proto-google-common-protos:1.0.2 (*)
|    |    \--- com.google.protobuf:protobuf-java:3.4.0
|    +--- com.google.api.grpc:proto-google-cloud-speech-v1:0.1.26
|    |    +--- com.google.api.grpc:proto-google-common-protos:1.0.2 (*)
|    |    \--- com.google.protobuf:protobuf-java:3.4.0
|    +--- io.grpc:grpc-netty:1.7.0 (*)
|    +--- io.grpc:grpc-stub:1.7.0 (*)
|    \--- io.grpc:grpc-auth:1.7.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 -> 3.0.0
     +--- com.google.http-client:google-http-client-jackson2:1.23.0 (*)
     \--- com.google.guava:guava-jdk5:17.0

debugAnnotationProcessor - Classpath for the annotation processor for 'debug'. (n)
No dependencies

debugAnnotationProcessorClasspath - Resolved configuration for annotation-processor for variant: debug
\--- com.google.cloud:google-cloud-speech:0.32.0-alpha
     +--- io.netty:netty-tcnative-boringssl-static:2.0.6.Final
     +--- com.google.cloud:google-cloud-core:1.14.0
     |    +--- com.google.guava:guava:20.0
     |    +--- joda-time:joda-time:2.9.2
     |    +--- org.json:json:20160810
     |    +--- com.google.http-client:google-http-client:1.23.0
     |    |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.0
     |    |    \--- 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:3.0.0
     |    +--- com.google.api:api-common:1.2.0
     |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    \--- com.google.guava:guava:19.0 -> 20.0
     |    +--- com.google.api:gax:1.15.0
     |    |    +--- com.google.auto.value:auto-value:1.2
     |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    +--- com.google.guava:guava:20.0
     |    |    +--- org.threeten:threetenbp:1.3.3
     |    |    +--- com.google.auth:google-auth-library-oauth2-http:0.9.0
     |    |    |    +--- com.google.auth:google-auth-library-credentials:0.9.0
     |    |    |    +--- com.google.http-client:google-http-client:1.19.0 -> 1.23.0 (*)
     |    |    |    +--- com.google.http-client:google-http-client-jackson2:1.19.0
     |    |    |    |    +--- com.google.http-client:google-http-client:1.19.0 -> 1.23.0 (*)
     |    |    |    |    \--- com.fasterxml.jackson.core:jackson-core:2.1.3
     |    |    |    \--- com.google.guava:guava:19.0 -> 20.0
     |    |    \--- com.google.api:api-common:1.2.0 (*)
     |    +--- com.google.protobuf:protobuf-java-util:3.4.0
     |    |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    |    +--- com.google.guava:guava:19.0 -> 20.0
     |    |    \--- com.google.code.gson:gson:2.7
     |    +--- com.google.api.grpc:proto-google-common-protos:1.0.2
     |    |    \--- com.google.protobuf:protobuf-java:3.4.0
     |    \--- com.google.api.grpc:proto-google-iam-v1:0.1.26
     |         +--- com.google.protobuf:protobuf-java:3.3.0 -> 3.4.0
     |         +--- com.google.api.grpc:proto-google-common-protos:1.0.2 (*)
     |         \--- com.google.api:api-common:1.1.0 -> 1.2.0 (*)
     +--- com.google.cloud:google-cloud-core-grpc:1.14.0
     |    +--- io.netty:netty-tcnative-boringssl-static:2.0.6.Final
     |    +--- com.google.auth:google-auth-library-credentials:0.9.0
     |    +--- com.google.cloud:google-cloud-core:1.14.0 (*)
     |    +--- com.google.guava:guava:20.0
     |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    +--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
     |    +--- io.grpc:grpc-protobuf:1.7.0
     |    |    +--- io.grpc:grpc-core:1.7.0
     |    |    |    +--- io.grpc:grpc-context:1.7.0
     |    |    |    +--- com.google.guava:guava:19.0 -> 20.0
     |    |    |    +--- com.google.errorprone:error_prone_annotations:2.0.19
     |    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    |    +--- com.google.instrumentation:instrumentation-api:0.4.3
     |    |    |    |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    |    |    |    \--- com.google.guava:guava:19.0 -> 20.0
     |    |    |    \--- io.opencensus:opencensus-api:0.6.0
     |    |    |         \--- com.google.guava:guava:19.0 -> 20.0
     |    |    +--- com.google.protobuf:protobuf-java:3.4.0
     |    |    +--- com.google.guava:guava:19.0 -> 20.0
     |    |    +--- com.google.protobuf:protobuf-java-util:3.4.0 (*)
     |    |    +--- com.google.api.grpc:proto-google-common-protos:0.1.9 -> 1.0.2 (*)
     |    |    \--- io.grpc:grpc-protobuf-lite:1.7.0
     |    |         +--- io.grpc:grpc-core:1.7.0 (*)
     |    |         \--- com.google.guava:guava:19.0 -> 20.0
     |    +--- io.grpc:grpc-context:1.7.0
     |    +--- io.grpc:grpc-netty:1.7.0
     |    |    +--- io.grpc:grpc-core:[1.7.0] -> 1.7.0 (*)
     |    |    +--- io.netty:netty-codec-http2:[4.1.16.Final] -> 4.1.16.Final
     |    |    |    +--- io.netty:netty-codec-http:4.1.16.Final
     |    |    |    |    \--- io.netty:netty-codec:4.1.16.Final
     |    |    |    |         \--- io.netty:netty-transport:4.1.16.Final
     |    |    |    |              +--- io.netty:netty-buffer:4.1.16.Final
     |    |    |    |              |    \--- io.netty:netty-common:4.1.16.Final
     |    |    |    |              \--- io.netty:netty-resolver:4.1.16.Final
     |    |    |    |                   \--- io.netty:netty-common:4.1.16.Final
     |    |    |    \--- io.netty:netty-handler:4.1.16.Final
     |    |    |         +--- io.netty:netty-buffer:4.1.16.Final (*)
     |    |    |         +--- io.netty:netty-transport:4.1.16.Final (*)
     |    |    |         \--- io.netty:netty-codec:4.1.16.Final (*)
     |    |    \--- io.netty:netty-handler-proxy:4.1.16.Final
     |    |         +--- io.netty:netty-transport:4.1.16.Final (*)
     |    |         +--- io.netty:netty-codec-socks:4.1.16.Final
     |    |         |    \--- io.netty:netty-codec:4.1.16.Final (*)
     |    |         \--- io.netty:netty-codec-http:4.1.16.Final (*)
     |    +--- io.grpc:grpc-stub:1.7.0
     |    |    \--- io.grpc:grpc-core:1.7.0 (*)
     |    +--- io.grpc:grpc-auth:1.7.0
     |    |    +--- io.grpc:grpc-core:[1.7.0] -> 1.7.0 (*)
     |    |    \--- com.google.auth:google-auth-library-credentials:0.4.0 -> 0.9.0
     |    \--- com.google.api:gax-grpc:1.15.0
     |         +--- com.google.auto.value:auto-value:1.2
     |         +--- com.google.code.findbugs:jsr305:3.0.0
     |         +--- com.google.api:gax:1.15.0 (*)
     |         +--- io.grpc:grpc-netty:1.7.0 (*)
     |         +--- io.grpc:grpc-stub:1.7.0 (*)
     |         +--- io.grpc:grpc-auth:1.7.0 (*)
     |         +--- io.grpc:grpc-protobuf:1.7.0 (*)
     |         +--- com.google.guava:guava:20.0
     |         +--- org.threeten:threetenbp:1.3.3
     |         +--- com.google.auth:google-auth-library-oauth2-http:0.9.0 (*)
     |         +--- com.google.auth:google-auth-library-credentials:0.9.0
     |         +--- com.google.api.grpc:proto-google-common-protos:1.0.0 -> 1.0.2 (*)
     |         \--- com.google.api:api-common:1.2.0 (*)
     +--- com.google.api.grpc:proto-google-cloud-speech-v1beta1:0.1.26
     |    +--- com.google.api.grpc:proto-google-common-protos:1.0.2 (*)
     |    \--- com.google.protobuf:protobuf-java:3.4.0
     +--- com.google.api.grpc:proto-google-cloud-speech-v1:0.1.26
     |    +--- com.google.api.grpc:proto-google-common-protos:1.0.2 (*)
     |    \--- com.google.protobuf:protobuf-java:3.4.0
     +--- io.grpc:grpc-netty:1.7.0 (*)
     +--- io.grpc:grpc-stub:1.7.0 (*)
     \--- io.grpc:grpc-auth:1.7.0 (*)

1 ответ

Я думаю, вы могли бы попытаться использовать библиотеку обновлений, которая использовалась в этом другом вопросе.

Как объясняется в ответе, "Getdown" можно использовать для обновления Java, а также приложений, не относящихся к Java.

Способ реализации функций указанной библиотеки объясняется в документе README пакета. Они ссылаются на дальнейший документ GitHub

Другие вопросы по тегам