I am a beginner of Android Studio and Google-Cloud API. I would like to use google-cloud-speech with google-api-client to use oauth. But now I struggled to build my code; it might have problem of duplication of library name.
To regenerate the build error, I make a new project and just put the following dependencies and packagingOptions in build.gradle (Module:app). It can build without android (virtual) device but it failed to build with android (virtual) device; in other words, it can build by (Build Menu) -> (Clean Project) but it fails by (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'
}
The error message is following,
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I googled the error, 'app:transformDexArchiveWithExternalLibsDexMergerForDebug' and I suppose it is related to the duplication of library names.
So I checked the dependency tree by the following command in command line.
$> gradlew app:dependencies
And I found the inconsistency of version of a library, 'com.google.http-client:google-http-client-jackson2' One of its version is 1.19.0 but all of others are 1.23.0. (Please see to check it the copy of the output of gradlew app:dependencies in the end of this post.)
I would like to know how to update a library in an external jar. Please let me know it.
A part of the output by 'gradlew app:dependencies'
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 (*)
I think you could try to use an update library as the one used in this other question
Pretty much as the answer there explains, "Getdown" can be used to update java and also non-Java applications.
The way to implement the functions of said library are explained in the README document of the package. They link to a further document of github
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.