我正在将我的Android应用项目从GCM
迁移到FCM
。为此,我使用Android Studio中的Firebase助手工具,并按照Google开发者指南中的说明进行操作。一切顺利,并根据助手工具更改了FCM
的应用代码。现在,该运行和测试应用程序了。而且我收到以下奇怪的错误:
无法访问未找到com.google.android.gms.internal.zzbfm的zzbfm类文件
我在使用Google地图并尝试设置标记位置时遇到此错误。 这是我的应用程序级别的gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
maven { url 'https://dl.bintray.com/kennyc1012/maven' }
}
android {
signingConfigs {
msapp {
}
}
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.package"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//Default
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-messaging:11.8.0'
testImplementation 'junit:junit:4.12'
//modules
implementation 'com.facebook.android:facebook-android-sdk:4.+'
//jar files
implementation files('libs/classes.jar')
implementation files('libs/YouTubeAndroidPlayerApi.jar')
//google repos
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:support-v4:26.0.0'
implementation 'com.android.support:recyclerview-v7:26.0.0'
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.android.support:design:26.0.0'
//square lib
implementation 'com.squareup.retrofit2:converter-gson:2.0.0'
//compile 'com.squareup.leakcanary:leakcanary-android:1.5'
//text manupulation
implementation 'commons-lang:commons-lang:2.6'
//permission library.
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:3)
To resolve your problem, first i will ask you to always use specified and updated version.
1. Replace + with specific version here : classpath 'io.fabric.tools:gradle:1.25.4'
2. Try to use same version for now to run the apk,
compileSdkVersion 27
buildToolsVersion '27.0.3'
targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
3. Use updated version of google play service
implementation 'com.google.android.gms:play-services:16.0.3'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
This will fix your problem.
答案 1 :(得分:1)
请将您的Firebase和Google库更改为相同版本。 对于这样的示例
--eviction-soft
答案 2 :(得分:1)
在大多数情况下,升级播放服务和Firebase版本依赖关系是必需的,如果您使用的是 androidx ,则可能是最后一个可用的,否则:
尝试将其检出maven_repository并选择一些有助于修复它的版本。例如:
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
由于v17.0.0需要androidx(在播放服务中),因此所选版本是版本17之前的最后一个版本
别忘了在build.gradle(project)中更新Google服务
classpath 'com.google.gms:google-services:4.3.0'
答案 3 :(得分:0)
根据有关Latest SDK versions的官方文档,请更改以下代码行:
implementation 'com.google.firebase:firebase-messaging:11.8.0'
到
implementation 'com.google.firebase:firebase-messaging:17.3.1'
根据有关set up Google Play Services的正式文档,请更改以下代码行:
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
到
//implementation 'com.google.android.gms:play-services:11.8.0' //Commented line
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.1
还请确保具有:
classpath 'com.google.gms:google-services:4.1.0'
在顶级build.gradle
文件中。
答案 4 :(得分:0)
在迁移 AndroidX 后,我遇到了相同的问题,并且 通过如下更改地图和位置的 gms库的版本来解决
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
答案 5 :(得分:0)
只需将库“ ...... gms:play-services .....”的版本更新为最新版本 要查看最新版本,请参阅此link