所有gms/firebase库必须使用完全相同的版本.找到版本15.1.0,15.0.2,15.0.1,15.0.0.

Ami*_*mir 14 android gradle firebase android-studio android-studio-3.0

尝试在我的项目中实现Firebase.

Gradle文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.ghaleh.myapplication"
    minSdkVersion 16
    targetSdkVersion 27
    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(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.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-messaging:15.0.2'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 15.1.0, 15.0.2, 15.0.1, 15.0.0. Examples include com.google.firebase:firebase-iid:15.1.0 and com.google.android.gms:play-services-measurement-base:15.0.2
Run Code Online (Sandbox Code Playgroud)

根据谷歌的Maven资源库,最新版本firebase-messaging是15.0.2,我收到错误firebase-iid:15.1.0 因此我无法升级firebase-messaging到更高版本或实现firebase-iid:15.1.0匹配版本.

我已经尝试过在这里推荐的其他解决方案:1,2,3,但其中非是有用的.

我也尝试了这个(但它似乎不是一个合适的解决方案):

implementation ('com.google.firebase:firebase-messaging:15.0.2') {
    exclude group: "com.google.android.gms"
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForBazaarDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Run Code Online (Sandbox Code Playgroud)

提前致谢.

Pet*_*dad 20

您需要更新google-service要使用的插件:

classpath 'com.google.gms:google-services:3.3.0'
Run Code Online (Sandbox Code Playgroud)

为了能够避免这些错误,还升级到android studio 3.1

如果您不使用Android Studio 3.1开发应用程序,则需要升级才能在IDE中获得正确的版本检查行为.

更多信息和步骤:

宣布新的SDK版本

编译未能完成:程序类型已存在:com.google.android.gms.internal.measurement.zzabn

  • 更新Android Studio之后,我尝试了所有答案,问题得到解决。谢谢。 (2认同)
  • 感谢您将链接添加到SDK版本管理博客!很有帮助。 (2认同)