java更新firebase crashlytics依赖项后出现“错误:包com.google.firebase.iid不存在”

gwbalxhn  于 2021-07-11  发布在  Java
关注(0)|答案(2)|浏览(501)

我已经从更新了我的firebase crashlytics

  1. implementation 'com.google.firebase:firebase-crashlytics:17.1.1'

  1. implementation 'com.google.firebase:firebase-crashlytics:17.3.0'

现在我得到这个错误:

  1. error: package com.google.firebase.iid does not exist

当我尝试导入时:

  1. import com.google.firebase.iid.FirebaseInstanceId;
  2. import com.google.firebase.iid.InstanceIdResult;

这是我的项目级build.gradle文件:

  1. buildscript {
  2. ext {
  3. kotlin_version = '1.3.72'
  4. }
  5. repositories {
  6. google()
  7. jcenter()
  8. mavenCentral()
  9. }
  10. dependencies {
  11. classpath 'com.android.tools.build:gradle:4.1.1'
  12. classpath 'com.google.gms:google-services:4.3.4'
  13. classpath 'com.google.firebase:perf-plugin:1.3.4'
  14. classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
  15. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20" }
  16. }
  17. allprojects {
  18. repositories {
  19. google()
  20. jcenter()
  21. }
  22. }
  23. task clean(type: Delete) {
  24. delete rootProject.buildDir
  25. }

这是我的应用程序级build.gradle文件:

  1. apply plugin: 'com.android.application'
  2. apply plugin: 'com.google.gms.google-services'
  3. apply plugin: 'com.google.firebase.firebase-perf'
  4. apply plugin: 'kotlin-android'
  5. apply plugin: 'kotlin-android-extensions'
  6. apply plugin: 'com.google.firebase.crashlytics'
  7. android {
  8. compileSdkVersion 30
  9. defaultConfig {
  10. applicationId "..."
  11. minSdkVersion 16
  12. targetSdkVersion 30
  13. versionCode ...
  14. versionName "..."
  15. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  16. vectorDrawables.useSupportLibrary = true
  17. }
  18. buildTypes {
  19. release {
  20. minifyEnabled true
  21. //shrinkResources true NOT SUPPORTED FOR DYNAMIC MODULES
  22. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  23. multiDexEnabled true
  24. }
  25. debug {
  26. multiDexEnabled true
  27. }
  28. }
  29. dynamicFeatures = [":premium", ':tutorial']
  30. compileOptions {
  31. sourceCompatibility = 1.8
  32. targetCompatibility = 1.8
  33. }
  34. }
  35. dependencies {
  36. implementation fileTree(dir: 'libs', include: ['*.jar'])
  37. api 'androidx.appcompat:appcompat:1.2.0'
  38. api 'com.google.android.material:material:1.2.1'
  39. api 'androidx.constraintlayout:constraintlayout:2.0.4'
  40. api 'com.google.android.play:core:1.8.3'
  41. api 'com.google.firebase:firebase-analytics:18.0.0'
  42. api 'com.google.firebase:firebase-perf:19.0.10'
  43. api 'com.google.firebase:firebase-invites:17.0.0'
  44. api 'com.google.firebase:firebase-firestore:22.0.0'
  45. api 'androidx.legacy:legacy-support-v4:1.0.0'
  46. api 'com.google.firebase:firebase-config:20.0.1'
  47. implementation 'com.google.firebase:firebase-appindexing:19.1.0'
  48. testImplementation 'junit:junit:4.12'
  49. androidTestImplementation 'androidx.test:runner:1.3.0'
  50. androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
  51. api 'androidx.navigation:navigation-fragment:2.3.1'
  52. api 'androidx.cardview:cardview:1.0.0'
  53. api 'androidx.recyclerview:recyclerview:1.1.0'
  54. api 'androidx.preference:preference:1.1.1'
  55. implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
  56. androidTestImplementation 'androidx.test:rules:1.3.0'
  57. api 'com.google.firebase:firebase-auth:20.0.1'
  58. api 'com.google.zxing:core:3.3.3'
  59. api 'com.android.billingclient:billing:3.0.1'
  60. //api 'com.facebook.android:facebook-android-sdk:5.15.3'
  61. implementation 'com.google.android.gms:play-services-ads-lite:19.5.0'
  62. implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
  63. implementation 'androidx.multidex:multidex:2.0.1'
  64. implementation 'com.google.android.datatransport:transport-runtime:2.2.5'
  65. }

firebase crashlytics依赖项版本17.1.1及更低版本不会发生此错误。
我已经试过了:
改建工程
清洁工程
使缓存无效并重新启动

j5fpnvbx

j5fpnvbx1#

如果有存储库,请尝试添加mavencentral()

  1. repositories {
  2. google()
  3. mavenCentral()

或者试试这个https://firebase.google.com/docs/crashlytics/troubleshooting
或更新到firebase crashlytics sdk后出现此错误

ufj5ltwl

ufj5ltwl2#

这个问题的解决办法是 FirebaseInstanceId 被贬值了。这意味着它不再包含在库中。
您可以在这里找到更多信息:https://firebase.google.com/docs/reference/android/com/google/firebase/iid/firebaseinstanceid

相关问题