程序类型已存在:com.google.android.gms.location.places.zza

Posted

技术标签:

【中文标题】程序类型已存在:com.google.android.gms.location.places.zza【英文标题】:Program type already present: com.google.android.gms.location.places.zza 【发布时间】:2019-07-28 23:39:12 【问题描述】:

我需要有关此问题的帮助。我不确定出了什么问题。这是应用程序级别的构建 gradle 代码。如果我注释掉其他播放服务实现,它会给我其他错误。

apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    android 
        compileSdkVersion 26
        defaultConfig 
            applicationId "com.rough.tuber.tuber"
            minSdkVersion 16
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        
        buildTypes 
            release 
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            
        
    

    dependencies 
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        //noinspection GradleCompatible
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.google.android.libraries.places:places:1.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.google.firebase:firebase-messaging:11.8.0'
        implementation 'com.google.firebase:firebase-storage:11.8.0'
        implementation 'com.google.firebase:firebase-auth:11.8.0'
        implementation 'com.google.firebase:firebase-firestore:11.8.0'
    //    implementation 'com.google.firebase:firebase-auth:11.8.0'
        implementation 'com.google.android.gms:play-services-maps:11.8.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
        implementation 'com.android.volley:volley:1.0.0'
        implementation 'com.google.firebase:firebase-core:11.8.0'
        implementation 'com.google.firebase:firebase-database:11.8.0'
        implementation 'com.firebase:firebase-client-android:2.4.0'
        implementation 'com.google.android.gms:play-services:11.8.0'
        implementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
        implementation 'com.android.support:multidex:1.0.3'
        implementation 'com.android.support:design:26.1.0'
        implementation 'com.firebaseui:firebase-ui:0.6.0'
        implementation ("com.github.bumptech.glide:glide:4.8.0") 
            exclude group: "com.android.support"
        
        implementation 'com.squareup.picasso:picasso:2.71828'
        implementation 'com.google.android.gms:play-services-places:11.8.0'
    
    apply plugin: 'com.google.gms.google-services'

如果我在实施中删除另一个播放服务,那么它会给我另一个错误。我不知道该怎么办。 我正在添加更多错误。

java.lang.RuntimeException: com.android.build.api.transform.TransformException: Error while generating the main dex list.
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)

原因:com.android.build.api.transform.TransformException:生成主 dex 列表时出错。 在 com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:127) 在 com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221) 在 com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217) 在 com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)

【问题讨论】:

可能是因为 gradle 中有两个 places api implementation 'com.google.android.libraries.places:places:1.0.0' implementation 'com.google.android.gms:play-services-places:11.8.0' 删除第一个 'com.google.android.libraries.places:places:1.0.0' 实现删除这个? 是的。如果它抛出错误请分享 // implementation 'com.google.android.gms:play-services-places:11.8.0' 评论此行并重新设计您在应用程序中使用的场所类。 我已经用错误日志编辑了这个问题,但它仍然给出了同样的错误。程序类型已经存在:com.google.android.gms.location.places.zza Messagekind=ERROR, text=程序类型已经存在:com.google.android.gms.location.places.zza,sources=[未知来源文件],工具名称=Optional.of(D8) @KuLdipPaTel 【参考方案1】:

尝试在您的 (app) build.gradle 文件中添加以下代码

configurations 
    exclude group: 'com.google.android.gms', module: 'play-services-base'
    exclude group: 'com.google.android.gms', module: 'play-services-places'
    exclude group: 'com.google.android.gms', module: 'play-services-location'

并将以下内容添加到您的依赖项中

implementation 'com.google.android.gms:play-services-base:11.8.0'
implementation 'com.google.android.gms:play-services-places:11.8.0'

【讨论】:

我正在使用这个实现 'com.google.android.libraries.places:places:1.0.0' 方法进行地图自动搜索。【参考方案2】:

使用捆绑包代替使用单独的包..它为我解决了..

implementation 'com.google.android.gms:play-services:12.0.1'

【讨论】:

以上是关于程序类型已存在:com.google.android.gms.location.places.zza的主要内容,如果未能解决你的问题,请参考以下文章

Android Studio - 错误:程序类型已存在

程序类型已存在:android.support.v7.util.AsyncListUtil $ 1

错误:程序类型已存在:android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat

Proguard NoClassDefFoundError

错误:程序类型已存在:android.support.design.widget.CoordinatorLayout$Behavior

程序类型已存在:com.google.android.gms.location.places.zza