【问题标题】:Updating Firebase core from version 16 to 17 causing compilaton error将 Firebase 核心从版本 16 更新到 17 导致编译错误
【发布时间】:2019-11-06 04:02:59
【问题描述】:

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

更新它的版本之后
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.

我的 build.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'
}

【问题讨论】:

    标签: android firebase gradle androidx


    【解决方案1】:

    尝试将compileSdkVersion改为:compileSdkVersion 28

    【讨论】:

    • 这将返回另一个错误错误:清单合并失败:属性 application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0. 0] AndroidManifest.xml:22:18-91 也存在于 [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory)。建议:在 AndroidManifest.xml:15:5-66:15 的 元素中添加 'tools:replace="android:appComponentFactory"' 以覆盖。
    • @JosefVancura 此错误与新的 firebase 库所需的 androidx 迁移有关。检查下面答案中描述的发行说明以及修复它的步骤。
    【解决方案2】:

    您可以查看official release notes

    警告:此版本是主要版本更新和重大更改。 Google Play 服务和 Firebase 的最新更新包括以下更改:

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

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

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

    compileSdkVersion 28
    

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

    【讨论】:

      猜你喜欢
      • 2018-11-29
      • 1970-01-01
      • 1970-01-01
      • 2022-09-26
      • 1970-01-01
      • 2023-04-05
      • 2021-03-23
      • 2023-01-13
      • 1970-01-01
      相关资源
      最近更新 更多