React-Native:react-native-fast-image无法与react-native一起正常工作,它给出了错误

时间:2019-07-10 07:42:52

标签: android react-native build.gradle android-manifest react-native-android

当我将react-native-fast-image与react-native一起使用时,会引发错误

    * What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
        is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-138 to override.

我的package.json文件是

    {
  "name": "FastImageDemmo",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.8.3",
    "react-native": "0.59.0",
    "react-native-fast-image": "^7.0.2"
  },
  "devDependencies": {
    "@babel/core": "^7.5.4",
    "@babel/runtime": "^7.5.4",
    "babel-jest": "^24.8.0",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.55.0",
    "react-test-renderer": "16.8.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

我的app.gradle是

dependencies {
implementation project(':react-native-fast-image')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"  // From node_modules

}

我尝试了许多解决方案,例如在gradle.properties中添加以下代码

android.useAndroidX=true
android.enableJetifier=true

但是解决方案不起作用。

我该怎么办?

2 个答案:

答案 0 :(得分:1)

我的问题已由解决:

 "react": "16.8.6",
 "react-native": "0.60.4",
 "react-native-fast-image": "^7.0.2",

答案 1 :(得分:0)

我的问题已通过将react-native-fast-image的版本从 7.0.2 降级到 6.0.3

得以解决