昨天,我的应用程序工作正常 .
今天,我不知道为什么,我重新打开Android Studio后,应用程序不再编译 .
显示的错误是
Program type already present: com.google.android.gms.internal.measurement.zzwp
Message{kind=ERROR, text=Program type already present: com.google.android.gms.internal.measurement.zzwp, sources=[Unknown source file], tool name=Optional.of(D8)}
我真的不知道发生了什么,我搜索了一切,没有任何效果 . 如果有人能帮助我,我真的很感激 . 我更改了所有依赖项和库以尝试解决它,但没有任何效果 .
这是build.gradle项目
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的build.gradle模块:app
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.doctordirectory"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
implementation fileTree(dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation ('com.facebook.android:audience-network-sdk:4.28.0',{
exclude group: 'com.google.android.gms'
})
implementation 'com.facebook.android:facebook-login:4.32.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
implementation 'com.android.support:support-v4:27.1.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'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-database:15.0.0'
implementation 'com.google.firebase:firebase-crash:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-storage:15.0.0'
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.google.android.gms:play-services-plus:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.stepstone.apprating:app-rating:2.2.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.github.lguipeng:BubbleView:1.0.1'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'com.github.MdFarhanRaja:SearchableSpinner:1.9'
implementation 'com.github.sillebille:dynamic-calendar:1.0.1'
implementation 'com.google.api-client:google-api-client:1.22.0'
implementation 'com.google.api-client:google-api-client-android:1.22.0'
implementation 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'
}
apply plugin: 'com.google.gms.google-services'
11 回答
我也有这个错误和我解决这个问题的方法
1)更新Firbase版本以独立于Google Play服务版本
你可以在这里查看最新版本https://firebase.google.com/support/release-notes/android#latest_sdk_versions
2)在顶级build.gradle文件中将google-services从3.1.1更新为3. 2 .1
我只是改变
implementation 'com.google.firebase:firebase-crash:15.0.0'
至
implementation 'com.google.firebase:firebase-crash:15.0.2'
有用 .
对我来说问题似乎是由android构建工具引起的
为了解决这个问题,我不得不在mu项目的顶级
build.gradle
文件中降级这些我知道这不是最好的解决方案,但到目前为止,唯一对我有用的东西 .
编辑:或者,将
android.enableD8=false
添加到项目gradle.properties
文件中Firebase is the reason they are updating version numbers like they don't care about the developers.
首先要做的事情 . 更新项目级gradle中的类路径
接下来,无论您使用什么工具,如分析,动态链接等等 . 使用适当的版本化依赖项 .
在我的情况下,我通过远程配置使用A / B测试,所以我需要更新它
到
这应该没有任何故障 . 此外,请将此类问题发布到Firebase,以便他们不会在没有正面或没有适当文档的情况下进行此类更改 .
更新您的firebase依赖项 .
1.项目级build.gradle
将
google.gms
版本更新为最新版本 . Track latest release . 在回答时最新是4.1.0
.2.应用程序级build.gradle
如果您使用any,请更新以下依赖项 . Note that firebase现在为每个依赖项都有各自的版本 .
使用latest Firebase Libraries . 在回答时,最新版本如下 .
3.不要忘记谷歌插件
另外,不要忘记在app level build.gradle底部添加
apply plugin: 'com.google.gms.google-services'
.Sync and Build...
在添加firebase analitycs last vesion之后发生了这种情况,就像这样
将版本更改为16.0.4有帮助
将
firebase dependencies
更新为最新版本com.google.firebase:firebase-core:15.0.0
至com.google.firebase:firebase-core:15.0.2
Get Latest List from here后解决此问题以下列表中的所有其他更改
2)在顶级build.gradle文件更新从
classpath 'com.google.gms:google-services:3.1.1
到classpath 'com.google.gms:google-services:3.2.1
我今天遇到了同样的问题 . Google于2018年5月2日推出新版本 .
请转到链接并根据文档设置版本号:
https://firebase.google.com/support/release-notes/android#20180502
例如
Firebase Core com.google.firebase:firebase-core:15.0.2
如果您遇到阻止编译的其他问题,请尝试将Google服务依赖项升级到 3.2.0 . 对我来说,至少3.2.1和3.3.0引起了问题,3.2.0就是那个有效的问题 .
好的,等一下 . 我已经确认并非所有Firebase库都需要该版本 . 版本现在未对齐 . 实际上在官方网页报道中有些是15.1.0而不是15.0.2;
也许直接在这里看看它是否有用:
https://firebase.google.com/docs/android/setup
删除包含“com.google.android.gms”的依赖项,然后尝试重建项目...你必须尝试点击尝试因为有一些依赖,它使用了两次
例如
com.android.support:design
添加了twise