首页 文章

Android Studio-程序类型已存在:com.google.android.gms.internal.measurement.zzwp

提问于
浏览
69

昨天,我的应用程序工作正常 .

今天,我不知道为什么,我重新打开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 回答

  • 20

    我也有这个错误和我解决这个问题的方法

    1)更新Firbase版本以独立于Google Play服务版本

    implementation "com.google.firebase:firebase-messaging:15.0.2"
    

    你可以在这里查看最新版本https://firebase.google.com/support/release-notes/android#latest_sdk_versions

    2)在顶级build.gradle文件中将google-services从3.1.1更新为3. 2 .1

    buildscript {
        dependencies {
    
            classpath 'com.google.gms:google-services:3.2.1'
    
        }
     }
    
  • 5

    我只是改变

    implementation 'com.google.firebase:firebase-crash:15.0.0'

    implementation 'com.google.firebase:firebase-crash:15.0.2'

    有用 .

  • 0

    对我来说问题似乎是由android构建工具引起的

    为了解决这个问题,我不得不在mu项目的顶级 build.gradle 文件中降级这些

    -        classpath 'com.android.tools.build:gradle:3.1.0'
    +        classpath 'com.android.tools.build:gradle:3.0.1'
    

    我知道这不是最好的解决方案,但到目前为止,唯一对我有用的东西 .

    编辑:或者,将 android.enableD8=false 添加到项目 gradle.properties 文件中

  • 1

    Firebase is the reason they are updating version numbers like they don't care about the developers.

    首先要做的事情 . 更新项目级gradle中的类路径

    dependencies {
    
            classpath 'com.google.gms:google-services:3.2.1'
    
        }
    

    接下来,无论您使用什么工具,如分析,动态链接等等 . 使用适当的版本化依赖项 .

    https://firebase.google.com/support/release-notes/android
    

    在我的情况下,我通过远程配置使用A / B测试,所以我需要更新它

    implementation 'com.google.firebase:firebase-config:15.0.0'
    

    implementation 'com.google.firebase:firebase-config:15.0.2'
    

    这应该没有任何故障 . 此外,请将此类问题发布到Firebase,以便他们不会在没有正面或没有适当文档的情况下进行此类更改 .

  • 3

    更新您的firebase依赖项 .

    1.项目级build.gradle

    google.gms 版本更新为最新版本 . Track latest release . 在回答时最新是 4.1.0 .

    buildscript {
        // ...
        dependencies {
            // ...
            classpath 'com.google.gms:google-services:4.1.0' // google-services plugin
        }
    }
    
    allprojects {
        // ...
        repositories {
            // ...
            google() // Google's Maven repository
        }
    }
    

    2.应用程序级build.gradle

    如果您使用any,请更新以下依赖项 . Note that firebase现在为每个依赖项都有各自的版本 .

    使用latest Firebase Libraries . 在回答时,最新版本如下 .

    Firebase Core                com.google.firebase:firebase-core:16.0.3
    Ads                          com.google.firebase:firebase-ads:15.0.1
    Analytics                    com.google.firebase:firebase-analytics:16.0.3
    App Indexing                 com.google.firebase:firebase-appindexing:16.0.1
    Authentication               com.google.firebase:firebase-auth:16.0.3
    Cloud Firestore              com.google.firebase:firebase-firestore:17.1.0
    Cloud Functions              com.google.firebase:firebase-functions:16.1.0
    Cloud Messaging              com.google.firebase:firebase-messaging:17.3.2
    Cloud Storage   c            om.google.firebase:firebase-storage:16.0.2
    Crash Reporting              com.google.firebase:firebase-crash:16.2.0
    Crashlytics                  com.crashlytics.sdk.android:crashlytics:2.9.5
    Dynamic Links                com.google.firebase:firebase-dynamic-links:16.1.1
    Invites                      com.google.firebase:firebase-invites:16.0.3
    In-App Messaging             com.google.firebase:firebase-inappmessaging:17.0.1
    In-App Messaging Display     com.google.firebase:firebase-inappmessaging-display:17.0.1
    ML Kit: Model Interpreter    com.google.firebase:firebase-ml-model-interpreter:16.2.0
    ML Kit: Vision               com.google.firebase:firebase-ml-vision:17.0.0
    ML Kit: Image Labeling       com.google.firebase:firebase-ml-vision-image-label-model:15.0.0
    Performance Monitoring       com.google.firebase:firebase-perf:16.1.0
    Realtime Database            com.google.firebase:firebase-database:16.0.2
    Remote Config                com.google.firebase:firebase-config:16.0.0
    

    3.不要忘记谷歌插件

    另外,不要忘记在app level build.gradle底部添加 apply plugin: 'com.google.gms.google-services' .

    Sync and Build...

  • 11

    在添加firebase analitycs last vesion之后发生了这种情况,就像这样

    implementation "com.google.firebase:firebase-core:16.0.5"
    

    将版本更改为16.0.4有帮助

    implementation "com.google.firebase:firebase-core:16.0.4"
    
  • 0

    firebase dependencies 更新为最新版本 com.google.firebase:firebase-core:15.0.0com.google.firebase:firebase-core:15.0.2 Get Latest List from here后解决此问题

    以下列表中的所有其他更改

    dependencies {
            implementation fileTree(dir: 'libs', include: ['*.jar'])
            implementation 'com.android.support:appcompat-v7:27.1.1'
            implementation 'com.android.support:customtabs:27.1.1'
            implementation 'com.android.support.constraint:constraint-layout:1.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.github.PhilJay:MPAndroidChart:v3.0.3'
    
            implementation 'com.facebook.android:audience-network-sdk:4.28.0'
            implementation 'com.facebook.android:facebook-login:4.32.0'
            implementation 'com.android.support:multidex:1.0.3'
    
            implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
    
            implementation 'com.android.support:support-v4:27.1.1'
            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.2'
            implementation 'com.google.firebase:firebase-database:15.0.0'
            implementation 'com.google.firebase:firebase-crash:15.0.2'
            implementation 'com.google.firebase:firebase-auth:15.0.0'
            implementation 'com.google.firebase:firebase-storage:15.0.2'
            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.1'
            implementation 'com.android.support:recyclerview-v7:27.1.1'
    
            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.1'
            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'
        }
    

    2)在顶级build.gradle文件更新从 classpath 'com.google.gms:google-services:3.1.1classpath 'com.google.gms:google-services:3.2.1

  • 2

    我今天遇到了同样的问题 . Google于2018年5月2日推出新版本 .

    请转到链接并根据文档设置版本号:

    https://firebase.google.com/support/release-notes/android#20180502

    例如

    Firebase Core com.google.firebase:firebase-core:15.0.2

  • 1

    如果您遇到阻止编译的其他问题,请尝试将Google服务依赖项升级到 3.2.0 . 对我来说,至少3.2.1和3.3.0引起了问题,3.2.0就是那个有效的问题 .

  • 86

    好的,等一下 . 我已经确认并非所有Firebase库都需要该版本 . 版本现在未对齐 . 实际上在官方网页报道中有些是15.1.0而不是15.0.2;

    也许直接在这里看看它是否有用:

    https://firebase.google.com/docs/android/setup

  • 4

    删除包含“com.google.android.gms”的依赖项,然后尝试重建项目...你必须尝试点击尝试因为有一些依赖,它使用了两次

    例如 com.android.support:design 添加了twise

相关问题