android - 将 Firebase 核心从版本 16 更新到 17 导致编译错误

标签 android firebase gradle androidx

在我的项目中,我使用 Firebase 分析。在我从

更新 gradle 版本之后
implementation 'com.google.firebase:firebase-core:16.0.7'

implementation 'com.google.firebase:firebase-core:17.0.0'

编译错误

Android resource linking failed
/Users/josefvancura/Desktop/Programing/Android/PepaApps/Dochazka/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:2663: error: resource android:attr/fontVariationSettings not found.
/Users/josefvancura/Desktop/Programing/Android/PepaApps/Dochazka/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:2663: error: resource android:attr/ttcIndex not found.
error: failed linking references.

我的构建.gradle

buildscript {
  repositories {
      maven { url 'https://maven.fabric.io/public' }
  }

  dependencies {
      classpath 'io.fabric.tools:gradle:1.27.0'
  }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
   compileSdkVersion 27    // Android 8.1.

defaultConfig {
    applicationId "cz.vancura.dochazka"
    minSdkVersion 21        // Android 5.0
    targetSdkVersion 27     // android 8.1
    versionCode 11          // vzdy plus 1
    versionName "5.5"
}

signingConfigs {
    buildTypes {
        debug {
            buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" + System.currentTimeMillis() + "L)"
        }
        release {
            buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" + System.currentTimeMillis() + "L)"
        }
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])

  implementation 'com.android.support:appcompat-v7:27.1.1'
  implementation 'com.android.support:preference-v7:27.1.1'
  implementation 'com.android.support:design:27.1.1'
  implementation 'com.android.support.constraint:constraint-layout:1.1.3'
  implementation 'com.android.support:cardview-v7:27.1.1'

  // update to version 17 - compile error, keep 16.0.7
  implementation 'com.google.firebase:firebase-core:16.0.7'

  implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
  implementation('com.crashlytics.sdk.android:crashlytics-ndk:2.0.3@aar') {
    transitive = true
}

  implementation 'com.github.hotchemi:android-rate:1.0.1'
  implementation 'com.opencsv:opencsv:4.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'

}

apply plugin: 'com.google.gms.google-services'

crashlytics {
  enableNdk true
  androidNdkOut 'src/main/obj'
  androidNdkLibsOut 'src/main/libs'
}

最佳答案

您可以查看 official release notes :

Warning: This release is a MAJOR version update and breaking change. The latest update to Google Play services and Firebase includes the following changes:

从 Android 支持库迁移到 Jetpack (AndroidX) 库。除非您在应用中进行以下更改,否则库将无法工作:

  • com.android.tools.build:gradle 升级到 v3.2.1 或更高版本。
  • compileSdkVersion升级到28或更高版本。
  • 更新您的应用以使用 Jetpack (AndroidX);按照迁移到 AndroidX 中的说明进行操作。

您必须将 compileSdkVersion 更改为 28 并迁移到 androidx 库。

compileSdkVersion 28

您还可以检查 fontVariationSettings属性。 它是在 api 级别 28 中添加的。

关于android - 将 Firebase 核心从版本 16 更新到 17 导致编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56735014/

相关文章:

android - 推送通知能否与 UI 线程并行执行代码?

android - 不同宽度的按钮未与 layout_weight 正确对齐

android - 如何更改饼图值文本大小?

java - 如何使用 libgdx/robovm 获取应用程序版本

android - 某些视频格式不适用于 mediaPlayer

java - 此应用无权在 app-release.apk 中使用 Firebase 身份验证

ios - dyld : Symbol not found: _OBJC_CLASS_$_GTMMIMEDocument after migrating to Swift 4. 2 和 Firebase 5.8

android - Dagger 2 : Gradle module dependency with implementation in another module

android - 如果另一个任务依赖于第一个任务运行,Gradle任务不会删除文件

android - 扩展函数无法从库中导入