AndroidStudio - 程序类型已经存在:com.google.android.gms.location.places.zza
Posted
技术标签:
【中文标题】AndroidStudio - 程序类型已经存在:com.google.android.gms.location.places.zza【英文标题】:AndroidStudio - Program type already present: com.google.android.gms.location.places.zza 【发布时间】:2019-03-27 20:54:37 【问题描述】:首先:让我解释一下情况,我有一个与 google Api 配合使用的 sdk 并实现了很多依赖项。然后我将 lib 实现到我的新应用程序中,该应用程序也实现了依赖项。在我尝试运行应用程序之前一切正常。当我(在设备上)运行我的项目时,我收到以下错误消息:
Error: Program type already present: com.google.android.gms.location.places.zza
在 Gradle 日志中使用以下堆栈跟踪(不是全部)
Program type already present: com.google.android.gms.location.places.zza
Learn how to resolve the issue at https://developer.android.com/studio/buil/dependencies#duplicate_classes. 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:230)
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:50)
这里是 build.gradle 项目(lib)
buildscript
repositories
google()
jcenter()
dependencies
//**------------Added Recently----------------**//
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.1.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
plugins
id "com.jfrog.bintray" version "1.7.3"
allprojects
repositories
google()
jcenter()
task clean(type: Delete)
delete rootProject.buildDir
这是 build.gradle Module:app(lib)
apply plugin: 'com.android.library'
archivesBaseName = "inngage-lib"
ext
PUBLISH_GROUP_ID = 'br.com.inngage.sdk'
PUBLISH_ARTIFACT_ID = 'inngage-lib'
PUBLISH_VERSION = '2.2.0'
android
lintOptions
abortOnError false
signingConfigs
w
release
keyAlias 'inngage-lib'
keyPassword '************************************'
storeFile file('/Users/Downloads/inngage-lib.keystore')
storePassword '***********************************'
compileSdkVersion 28
useLibrary 'org.apache.http.legacy'
defaultConfig
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
debug
minifyEnabled false
dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
//noinspection UseOfBundledGooglePlayServices
//implementation 'com.google.android.gms:play-services:12.0.1'
// implementation "com.google.android.gms:play-services-base:16.0.1"
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-iid:16.0.0'
testImplementation 'junit:junit:4.12'
apply plugin: 'com.google.gms.google-services'
apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
apply plugin: 'com.jfrog.bintray'
这里是 build.gradle 项目(**我的应用程序**)
buildscript
repositories
maven url "https://dl.bintray.com/inngage/repo"
google()
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
allprojects
repositories
maven url "https://dl.bintray.com/inngage/repo"
google()
jcenter()
task clean(type: Delete)
delete rootProject.buildDir
这是 build.gradle Module:app(** my App**)
apply plugin: 'com.android.application'
android
compileSdkVersion 28
defaultConfig
applicationId "com.admin.sdk_test"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
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:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
/* added */
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
/* Inngage SDK*/
implementation 'br.com.inngage.sdk:inngage-lib:2.2.0'
/*---------------*/
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
apply plugin: 'com.google.gms.google-services'
【问题讨论】:
【参考方案1】:我添加了这个依赖,它工作正常!
implementation 'com.google.android.gms:play-services-places:16.0.0'
【讨论】:
@RAHUL 在我的情况下,也许在你的情况下你正在使用 google-play-services ('com.google.android.gms:play-services:12.0.1') ?因为如果是,那将添加导致问题的重复依赖项。 @RAHUL 太好了 ;)【参考方案2】:already present
从不是由缺少依赖引起的...
implementation ("br.com.inngage.sdk:inngage-lib:2.2.0")
exclude group: "com.google.android.gms", module: "play-services"
看看MavenCentral,它添加了一些重复和过时的依赖项。
【讨论】:
非常感谢【参考方案3】:问题是,如果您可以找到需要 com.google.android.gms.location 的实现,您可以在它下面排除 com.google.android.gms 或简单地在构建中找到具有不同版本的重复依赖项。 gradle 模块:项目
ext
googlePlayServicesVersion = "16.0.0"
【讨论】:
感谢您的帮助,但这是一个 misibg 依赖实现 'com.google.android.gms:play-services-places:16.0.0'以上是关于AndroidStudio - 程序类型已经存在:com.google.android.gms.location.places.zza的主要内容,如果未能解决你的问题,请参考以下文章
错误:程序类型已存在:android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior