【问题标题】:Android Studio- Program type already present: com.google.android.gms.internal.measurement.zzwpAndroid Studio - 程序类型已经存在:com.google.android.gms.internal.measurement.zzwp
【发布时间】:2018-10-13 06:31:12
【问题描述】:

昨天,我的应用运行良好。

今天不知道是什么原因,我重新打开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'

【问题讨论】:

  • 这一定是人们不喜欢自动更新依赖的原因...
  • @immibis 没找到你。您的意思是即使我们提到了特定版本,firebase 也会自动更新?

标签: android firebase android-studio jar


【解决方案1】:

在将firebase dependencies 更新为最新版本后解决了此问题,例如将com.google.firebase:firebase-core:15.0.0 更新为com.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

【讨论】:

  • 此解决方案有效。 Firebase 现在正在分发具有独立版本号的软件包,确保 build.gradle 上的所有软件包都是最新的。
  • 成功了。非常感谢。我试图更新一些东西,但我从未想过 firebase 会改变它。谢谢。
  • 很高兴您已从我的回答中编辑并添加了第二部分,因为您的回答已被接受;)
  • m 也有另一种问题“程序类型已经存在:org.apache.http.io.HttpMessageParser Message{kind=ERROR, text=Program type already present: org.apache.http.io .HttpMessageParser,sources=[Unknown source file], tool name=Optional.of(D8)}," m 使用最新版本的firebase和最新版本的支持,设计库,也是我项目的build.gradle包含类路径'com.android .tools.build:gradle:3.1.2' 类路径 'com.google.gms:google-services:4.0.0',仍然出现问题..
  • 我已经看到,最好的解决方案是将这些依赖项更新到他们网站上显示的最新版本,而不是 gradle 文件中显示的最新版本
【解决方案2】:

我也遇到了这个错误,我对此问题的解决方案

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'

    }
 }

【讨论】:

    【解决方案3】:

    我只是改变

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

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

    它有效。

    【讨论】:

      【解决方案4】:

      Firebase 是他们更新版本号的原因,就像他们不关心开发者一样。

      首先要做的事情。更新项目级 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,这样他们就不会在没有提示或没有适当文档的情况下进行此类更改。

      【讨论】:

      • “Firebase 是他们更新版本号的原因,就像他们不关心开发人员一样。”说得好?
      【解决方案5】:

      更新您的 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

      如果您使用任何依赖项,请更新以下依赖项。 请注意, 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。不要忘记谷歌插件

      另外不要忘记在应用级 build.gradle 的底部添加apply plugin: 'com.google.gms.google-services'

      同步和构建...

      【讨论】:

      • 关于检查最新版本的好技巧。我更喜欢使用bintray.com/android/android-tools/… 来查看google-services 的最新版本。 mvn 页面的CentralSprings Plugins 部分非常混乱。
      【解决方案6】:

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

      例如com.android.support:design 两次添加

      【讨论】:

        【解决方案7】:

        我今天遇到了同样的问题。 Google 将于 2018 年 5 月 2 日发布新版本。

        请根据文档进入链接设置版本号:

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

        例如

        Firebase 核心 com.google.firebase:firebase-core:15.0.2

        【讨论】:

          【解决方案8】:

          在上一个版本添加 firebase analitycs 后发生在我身上,就像这样

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

          将版本更改为 16.0.4 有帮助

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

          【讨论】:

            【解决方案9】:

            对我来说,问题似乎是由 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 文件中

            【讨论】:

              【解决方案10】:

              注释掉以下依赖为我解决了这个问题:

              implementation 'com.google.android.gms:play-services-analytics::16.0.7'
              

              【讨论】:

                【解决方案11】:
                allprojects {
                    repositories {
                    //start here
                    configurations.all {
                 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                   def requested = details.requested
                       if (requested.group == 'com.google.android.gms') {
                          details.useVersion '12.0.1'
                       }
                       if (requested.group == 'com.google.firebase') {
                          details.useVersion '12.0.1'
                         }
                       }
                     }
                    //end
                     jcenter()
                       maven {
                         url "https://maven.google.com"
                       }
                     }
                 }
                

                【讨论】:

                  【解决方案12】:

                  好的,请稍等。 我已经验证并非所有 Firebase 库都需要该版本。现在版本错位了。 事实上,在官方页面上报告说有些是 15.1.0 而不是 15.0.2;

                  如果有用的话可以直接看这里:

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

                  【讨论】:

                    【解决方案13】:

                    我也遇到过类似的错误:

                    程序类型已存在:com.google.android.gms.internal.*

                    我同时使用 OneSignal 和 React 原生地图, 我从两者中排除了 gms 并将其包含在上层。

                    请参阅此处的故障排除部分: https://github.com/react-native-community/react-native-maps/blob/master/docs/installation.md#troubleshooting

                    【讨论】:

                      【解决方案14】:

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

                      【讨论】:

                      • 但我认为构建 crashlytics 需要 3.2.1?
                      • @j2emanue 我个人没有使用 Crashlytics,所以我无法确认,但 3.2.1 和 3.3.0 都阻止了其他依赖项的编译。
                      猜你喜欢
                      • 1970-01-01
                      • 1970-01-01
                      • 2019-12-11
                      • 2018-06-29
                      • 2019-01-21
                      • 2019-04-22
                      • 1970-01-01
                      • 2018-09-23
                      • 2019-02-22
                      相关资源
                      最近更新 更多