I'm testing and Android app using various frameworks like Robolectric and Mockito. I have an app main project and a related "Libraries" project, linked with the first one and shared with other app. I need to test a Service class in my Libraries using instrumentation test and Robolectric (that I used massively in my JVM test also in Libraries). When I add
androidTestImplementation 'org.robolectric:robolectric:4.3'
to my Module:libraries build.gradle the build goes fine, but when I launch my instrumented test i got this error
Duplicate class com.google.protobuf.AbstractMessage found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.AbstractMessage$Builder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.AbstractMessageLite found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.AbstractParser found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.BlockingRpcChannel found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.BlockingService found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.BoundedByteString found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.BoundedByteString$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.BoundedByteString$BoundedByteIterator found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.ByteString found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.ByteString$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.ByteString$ByteIterator found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.ByteString$CodedBuilder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.ByteString$Output found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.CodedInputStream found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.CodedInputStream$RefillCallback found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.CodedInputStream$SkippedDataSink found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.CodedOutputStream found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.CodedOutputStream$ByteBufferOutputStream found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.CodedOutputStream$OutOfSpaceException found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProto found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProto$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProto$Builder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange$Builder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRangeOrBuilder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$DescriptorProtoOrBuilder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumDescriptorProto found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumDescriptorProto$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumDescriptorProto$Builder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumDescriptorProtoOrBuilder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumOptions found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumOptions$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumOptions$Builder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumOptionsOrBuilder found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumValueDescriptorProto found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
Duplicate class com.google.protobuf.DescriptorProtos$EnumValueDescriptorProto$1 found in modules lifesense_ble_v3.3.7.jar (lifesense_ble_v3.3.7.jar) and protobuf-java-2.6.1.jar (com.google.protobuf:protobuf-java:2.6.1)
...
Duplicate class org.apache.maven.artifact.installer.ArtifactInstallationException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.installer.ArtifactInstaller found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.installer.DefaultArtifactInstaller found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.ChecksumFailedException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.DefaultWagonManager found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.DefaultWagonManager$1 found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.DefaultWagonManager$2 found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.DefaultWagonProviderMapping found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.WagonComponentConfigurator found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.WagonConfigurationException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.WagonManager found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.manager.WagonProviderMapping found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.metadata.AbstractArtifactMetadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.metadata.ArtifactMetadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.metadata.ArtifactMetadataSource found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.metadata.ResolutionGroup found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.ArtifactRepository found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.ArtifactRepositoryFactory found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.ArtifactRepositoryPolicy found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.DefaultArtifactRepository found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.DefaultRepositoryMetadataManager found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.Metadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-repository-metadata-2.2.1.jar (org.apache.maven:maven-repository-metadata:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.Plugin found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-repository-metadata-2.2.1.jar (org.apache.maven:maven-repository-metadata:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.RepositoryMetadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.RepositoryMetadataDeploymentException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.RepositoryMetadataInstallationException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.RepositoryMetadataReadException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.Snapshot found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-repository-metadata-2.2.1.jar (org.apache.maven:maven-repository-metadata:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-manager-2.2.1.jar (org.apache.maven:maven-artifact-manager:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.Versioning found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-repository-metadata-2.2.1.jar (org.apache.maven:maven-repository-metadata:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-repository-metadata-2.2.1.jar (org.apache.maven:maven-repository-metadata:2.2.1)
Duplicate class org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-repository-metadata-2.2.1.jar (org.apache.maven:maven-repository-metadata:2.2.1)
Duplicate class org.apache.maven.artifact.resolver.AbstractArtifactResolutionException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.resolver.ArtifactCollector found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Duplicate class org.apache.maven.artifact.resolver.ArtifactNotFoundException found in modules maven-ant-tasks-2.1.3.jar (org.apache.maven:maven-ant-tasks:2.1.3) and maven-artifact-2.2.1.jar (org.apache.maven:maven-artifact:2.2.1)
Go to the documentation to learn how to Fix dependency resolution errors.
I tried to exclude, for example, the Protobuff using:
androidTestImplementation 'org.robolectric:robolectric:4.3' {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
obtain in this case
ERROR: Could not find method org.robolectric:robolectric:4.3() for arguments [build_byuvhyax0s1u9skwzk0q7eedm$_run_closure2$_closure16#4efcea4d] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File
These are my dependecies in gradle:
[app]
dependencies {
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:preference-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
implementation "commons-io:commons-io:$rootProject.commonsioVersion"
// Dependencies for ButterKnife
implementation "com.jakewharton:butterknife:$rootProject.butterknifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterknifeVersion"
// Dependencies for Dagger
implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
// Dependencies for RxBinding
implementation "com.jakewharton.rxbinding2:rxbinding:$rootProject.rxBindingVersion"
// Dependencies for Rxjava2 and RxAndroid
implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxAndroidVersion"
implementation "io.reactivex.rxjava2:rxjava:$rootProject.rxJavaVersion"
// Dependencies for Retrofit
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
implementation "com.squareup.retrofit2:converter-simplexml:$rootProject.retrofitConverterSimplexmlVersion"
implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:$rootProject.retrofitRxjavaAdapterVersion"
implementation "com.squareup.okhttp:okhttp:$rootProject.okhttpVersion"
// Dependencies for Room
implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
// Glide
implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
// AndroidX
testImplementation ('androidx.test:rules:1.1.0') {
exclude module:'kxml2'
}
// Dependencies for JUnit
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "junit:junit:$rootProject.junitVersion"
// Mockito framework
testImplementation 'org.mockito:mockito-core:2.4.0'
testImplementation "org.robolectric:robolectric:4.3"
// Multidex
implementation "com.android.support:multidex:$rootProject.multidexVersion"
implementation project(path: ':libraries')
}
[libraries]
dependencies {
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
implementation "commons-io:commons-io:$rootProject.commonsioVersion"
// Dependencies for RxBinding
implementation "com.jakewharton.rxbinding2:rxbinding:$rootProject.rxBindingVersion"
// Dependencies for Rxjava2 and RxAndroid
implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxAndroidVersion"
implementation "io.reactivex.rxjava2:rxjava:$rootProject.rxJavaVersion"
// Dependencies for Retrofit
implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
implementation "com.squareup.retrofit2:converter-simplexml:$rootProject.retrofitConverterSimplexmlVersion"
implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:$rootProject.retrofitRxjavaAdapterVersion"
implementation "com.squareup.okhttp:okhttp:$rootProject.okhttpVersion"
// Dependencies for Room
// Room (use 1.1.0-alpha1 for latest alpha)
implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
implementation "android.arch.persistence.room:rxjava2:$rootProject.roomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
implementation "com.android.support:support-annotations:$rootProject.supportLibraryVersion"
//implementation "org.apache.httpcomponents:httpcore:$rootProject.httpcoreVersion"
// Dependencies for JUnit
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation ('androidx.test:runner:1.1.0') {
exclude module:'kxml2'
}
testImplementation ('androidx.test:runner:1.1.0') {
exclude module:'kxml2'
}
androidTestImplementation ('androidx.test:rules:1.1.0') {
exclude module:'kxml2'
}
testImplementation ('androidx.test:rules:1.1.0') {
exclude module:'kxml2'
}
// Mockito framework
testImplementation 'org.mockito:mockito-core:2.13.0'
testImplementation "org.robolectric:robolectric:4.3"
androidTestImplementation 'org.robolectric:robolectric:4.3'
// Multidex
implementation "com.android.support:multidex:$rootProject.multidexVersion"
api files('libs/lifesense_ble_v3.3.7.jar')
api files('libs/pulselibrary-release.aar')
api files('libs/CreativeHealth_pc60nw.jar')
}
I don't understand the problem deeply and I didn't find a much about it. How can i solve this conflicts due to run my instrumented test?
Thanks in advance
Your solution to exclude protobuf-java from Robolectric is the right one, but I believe your problem comes from the syntax - you forgot parenthesis.
Try again with the following:
androidTestImplementation ('org.robolectric:robolectric:4.3') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
Also it seems like you use Robolectric on the testImplementation configuration, so you might want to add the following:
testImplementation ('org.robolectric:robolectric:4.3') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
Related
I have the following configuration:
Android Studio Electric Eel | 2022.1.1
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
dependencies.gradle:
ext.versions = [
minSdkLib : 23,
compileSdk : 33,
versionCode : 6,
versionName : '1.0.6',
kotlin_version : '1.7.21',
hilt_android : '2.40.1',
hilt_compiler : '2.40.1',
]
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: './dependencies.gradle'
repositories {
google()
mavenCentral()
gradlePluginPortal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$versions.hilt_android"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app)
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'dagger.hilt.android.plugin'
}
apply from: '../dependencies.gradle'
android {
compileSdkVersion versions.compileSdk
buildToolsVersion "30.0.3"
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildFeatures {
dataBinding = true
// for view binding:
viewBinding true
}
defaultConfig {
applicationId "****"
manifestPlaceholders = [hostName: "****"]
minSdkVersion versions.minSdkLib
targetSdkVersion versions.compileSdk
versionCode versions.versionCode
//versionCode buildDateTime
versionName versions.versionName
setProperty("archivesBaseName", "****")
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
"****"
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation 'androidx.annotation:annotation:1.5.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-common-java8:2.5.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
/*work */
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'com.google.android.material:material:1.7.0'
// Added Dependencies
implementation "androidx.recyclerview:recyclerview:1.2.1"
//
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'androidx.activity:activity-ktx:1.6.1'
implementation("io.coil-kt:coil:1.2.0")
/*Marshmallow permission*/
implementation 'com.karumi:dexter:6.2.3'
/*This is a logger with a small, extensible API which provides utility on top of Android's normal Log class.*/
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation "com.squareup.okhttp3:okhttp:4.10.0"
implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
implementation "com.squareup.moshi:moshi-kotlin:1.13.0"
implementation 'com.squareup.moshi:moshi:1.13.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.13.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
//Dagger Hilt
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03'
implementation "com.google.dagger:hilt-android:$versions.hilt_android"
implementation 'org.chromium.net:cronet-embedded:76.3809.111'
kapt "com.google.dagger:hilt-android-compiler:$versions.hilt_compiler"
kapt 'androidx.hilt:hilt-compiler:1.0.0'
// Paging
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
/*kotlin coroutines*/
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0"
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2")
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
/*ssp for text size for all multiple devices*/
implementation 'com.intuit.ssp:ssp-android:1.0.6'
/*sdp for all multiple devices size*/
implementation 'com.intuit.sdp:sdp-android:1.0.6'
/*Image picker and Camera*/
implementation 'com.github.dhaval2404:imagepicker:2.1'
//Biometric
implementation 'androidx.biometric:biometric:1.1.0'
//FCM
implementation platform('com.google.firebase:firebase-bom:31.0.2')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-messaging-ktx'
//Calendar
implementation 'com.applandeo:material-calendar-view:1.8.0-rc01'
//Horizontal Calendar
implementation 'devs.mulham.horizontalcalendar:horizontalcalendar:1.3.4'
//Stripe SDK
implementation 'com.stripe:stripe-android:20.16.1'
//Testing Libs
testImplementation 'junit:junit:4.13.2'
testImplementation "com.google.truth:truth:1.1.3"
androidTestImplementation "com.google.truth:truth:1.1.3"
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.test:core-ktx:1.4.0"
debugImplementation 'androidx.fragment:fragment-testing:1.5.4'
implementation 'de.hdodenhof:circleimageview:3.1.0'
///Zoom image
implementation 'com.jsibbold:zoomage:1.3.1'
///S: glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
//Bar
implementation 'com.github.hadiidbouk:ChartProgressBar-Android:2.0.6'
// One Signal
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
// Color picker
implementation 'com.github.yukuku:ambilwarna:2.0.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.1'
implementation group: 'com.squareup.retrofit2', name: 'adapter-rxjava2', version: '2.6.1'
// Toast
implementation 'com.github.ahmmedrejowan.CuteToast:CuteToast:1.2'
}
I have the following errors:
1: Task failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.io.path.DirectoryEntriesReader found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.ExperimentalPathApi found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.FileVisitorBuilder found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.FileVisitorBuilderImpl found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.FileVisitorImpl found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.LinkFollowing found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathNode found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathRelativizer found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalk found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalk$bfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalk$dfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalkKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathWalkOption found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.jdk7.AutoCloseableKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.jvm.optionals.OptionalsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Caused by: java.lang.RuntimeException: Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Caused by: java.lang.RuntimeException: Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.io.path.DirectoryEntriesReader found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.ExperimentalPathApi found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.FileVisitorBuilder found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.FileVisitorBuilderImpl found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.FileVisitorImpl found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.LinkFollowing found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathNode found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathRelativizer found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalk found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalk$bfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalk$dfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathTreeWalkKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathWalkOption found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.jdk7.AutoCloseableKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.21)
Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.jvm.optionals.OptionalsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21)
I don't understand why it tries to get the classes compiled with Kotlin 1.8.0. I don't have anywhere in the project used this version of Kotlin. I tried multiple version of gradle. I updated the Android Studio and some of the libraries.
I am stuck with this problem for 2 days. Please help! I can share more info about the project if needed.
Many thanks!
For me it was strange because I didn't even include these dependencies.
However, excluding kotlin-stdlib-jdk8 worked.
Add the following in build.gradle (:app)
configurations.implementation {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}
modules { module('org.jetbrains.kotlin:kotlin-stdlib-jdk8') { replacedBy 'org.jetbrains.kotlin:kotlin-stdlib', 'kotlin fixes' } module('org.jetbrains.kotlin:kotlin-stdlib-jdk7') { replacedBy 'org.jetbrains.kotlin:kotlin-stdlib', 'kotlin fixes' } }
This one given by #Adam Marr worked only.
I am building my project and getting the following errors of duplicate class
Duplicate class android.support.customtabs.ICustomTabsCallback found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.ICustomTabsCallback$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.ICustomTabsCallback$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.ICustomTabsService found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.ICustomTabsService$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.ICustomTabsService$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.IPostMessageService found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.IPostMessageService$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.customtabs.IPostMessageService$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and customtabs-26.1.0-runtime (com.android.support:customtabs:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.7.0-runtime (androidx.core:core:1.7.0) and support-compat-26.1.0-runtime (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.7.0-runtime (androidx.core:core:1.7.0) and support-compat-26.1.0-runtime (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.7.0-runtime (androidx.core:core:1.7.0) and support-compat-26.1.0-runtime (com.android.support:support-compat:26.1.0)
These are my gradle dependencies
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation files('libs/release.aar')
implementation "androidx.browser:browser:1.3.0"
implementation "com.google.android.gms:play-services-ads:16.0.0"
implementation "com.google.android.gms:play-services-location:16.0.0"
implementation "com.google.android.exoplayer:exoplayer:2.17.1"
implementation "com.google.android.exoplayer:extension-ima:2.17.1"
}
Was to able to solve by adding android.enableJetifier=true in gradle.properties file
I am developing android application that uses firebase ml kit to recognize text from image after importing firebase libraries when i run the application I catch this error:
Duplicate class com.google.android.gms.internal.vision.zze found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzf found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzg found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzh found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzi found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzv found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzw found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Go to the documentation to learn how to Fix dependency resolution errors.
here is my dependency in build gradle(Module : app)
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-ml-vision:24.0.3'
}
and my build.gradle (project):
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
classpath 'com.google.gms:google-services:4.3.4'
}
}
I am having an android project using firestore, firebase-auth and FCM . Now when I am adding google-cloud-texttospeech to my project I am getting 'Duplicate class' error
Here is my dependencies
//Firebase
implementation "com.google.firebase:firebase-core:17.0.0"
implementation "com.google.firebase:firebase-firestore:20.1.0"
/*implementation "com.crashlytics.sdk.android:crashlytics:$rootProject.crashlytics"*/
implementation "com.google.firebase:firebase-messaging:19.0.1"
implementation "com.google.firebase:firebase-auth:18.0.0"
// Ad-mob
implementation "com.google.android.gms:play-services-ads:18.0.0"
implementation ("com.google.cloud:google-cloud-texttospeech:0.97.0-beta")
This is the error I am getting while building the project.
Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AdviceOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AnnotationsProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProviderOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirementOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthenticationOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthenticationRule found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Now I understand the firebase and google-cloud-texttospeech is using same classes inside there dependencies.
So I tried to exclude those by
implementation ("com.google.cloud:google-cloud-texttospeech:0.97.0-beta"){
exclude group: 'com.google.api.grpc', module: 'proto-google-common-protos'
exclude group: 'com.google.protobuf', module: 'protobuf-lite'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
Then the app is building but crashes while speech synthesising
2019-07-03 20:04:15.861 24851-24851/package.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: package.dev, PID: 24851
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/protobuf/GeneratedMessageV3;
at com.google.cloud.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:101)
at package_name.tts.TextSpeachAPI.<init>(TextSpeachAPI.kt:8)
at package_name.ui.home.sofar.WordDetailsVM.speak(WordDetailsVM.kt:318)
at package_name.ui.home.sofar.WordDetailsFragment$listeners$11.onClick(WordDetailsFragment.kt:264)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.protobuf.GeneratedMessageV3" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/package_name.dev-apgPZPeLvH3LUXKWw2gBbg==/base.apk"],nativeLibraryDirectories=[/data/app/package_name.dev-apgPZPeLvH3LUXKWw2gBbg==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.cloud.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:101)
at package_name.tts.TextSpeachAPI.<init>(TextSpeachAPI.kt:8)
at package_name.ui.home.sofar.WordDetailsVM.speak(WordDetailsVM.kt:318)
at package_name.ui.home.sofar.WordDetailsFragment$listeners$11.onClick(WordDetailsFragment.kt:264)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I experienced such a problem when using "google cloud speech".
In the use of "firestore" and "google cloud speech", I showed duplicate classes in "protobuf-java", "protobuf-lite", "proto-google-common-protos" and "protolite-well-known-types" I solved the problem by unzipping the jar files and creating a new jar file with no duplicate classes. Please refer to the github project I posted below.
https://github.com/ivso0001/GoogleCloudSpeechAndFirebaseIntegration
This worked for me:
android{
...
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies{
...
implementation ('com.google.cloud:google-cloud-speech:0.41.0-alpha'){
exclude module: 'protobuf-javalite'
exclude module: 'protobuf-java'
exclude module: 'proto-google-common-protos'
}
}
Ref:
https://github.com/GoogleCloudPlatform/android-docs-samples/blob/master/speech/SpeechRecognitionClient/app/build.gradle
https://stackoverflow.com/a/64226363/8459761
I'm getting duplicate class errors when I try to build android app that use firebase-firestore and google-cloud-language.
Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
Duplicate class com.google.api.Advice$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
Duplicate class com.google.api.Advice$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
Duplicate class com.google.api.AdviceOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
...
Duplicate class com.google.type.TimeOfDayProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
My build.gradle looks like follow:
...
dependencies {
...
implementation 'com.google.firebase:firebase-ml-vision:20.0.0'
implementation 'com.google.firebase:firebase-firestore:19.0.0'
implementation 'io.grpc:grpc-okhttp:1.19.0'
implementation'com.google.cloud:google-cloud-language:1.76.0'
}
How can I solve the issuse ?