【问题标题】:Unable to find a matching configuration of project :react-native-firebase找不到项目的匹配配置:react-native-firebase
【发布时间】:2019-07-30 08:50:49
【问题描述】:

我有一个 React Native 版本 0.60.4 应用程序,我在其中安装了 react-native-firebase 版本 "^5.2.3"。现在当我给react-native run-android 它显示以下错误:

我无法链接 react-native-firebase,因为 react-native 0.60.4 不支持它。我试过运行cd android && gradlew clean && cd .. && react-native run-android,但没有运气。这是我的 android/app/build.gradle :

apply plugin: "com.android.application"
import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion 28

    compileOptions {
        sourceCompatibility '1.8'
        targetCompatibility '1.8'
    }

    defaultConfig {
        applicationId "com.movitpilot"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        // minifyEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }

    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
    buildToolsVersion = '28.0.3'
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  
    

    if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }
}

task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.google.gms.google-services'

任何帮助将不胜感激。

【问题讨论】:

  • 通知您的问题是否已解决!
  • 不,不是。 settings.gradle 文件只包含以下内容: rootProject.name = 'myproject' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 包括 ':app'
  • 那不应该像你分享的那样带来错误!请检查 PackageList.java。

标签: react-native react-native-firebase


【解决方案1】:

尝试从build.gralde 文件中删除implementation project(':react-native-firebase')。根据新的自动链接流程,无需在app/build.gradle 中实施项目。
还要确保settings.gradle 中没有像这样链接的模块:

rootProject.name = 'MyApp'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

如果有任何尝试通过react-native unlink react-native-firebase 取消链接模块如果您使用的是 react-native >= 0.60

【讨论】:

  • 试过了。还是一样。 @MatinZD
  • @TanmoySarker 这怎么可能!同样的错误!?
  • 是的,还是一样。
  • 请再次分享您的build.gradle 文件或按照我说的更新您的帖子。
  • 尝试取消链接您的模块。 react-native unlink react-native-firebase 然后react-native run-android
【解决方案2】:

我的解决方案是再次安装

npm i react-native-firebase@5.2.3

您需要检查react-native-firebase是否存在于文件夹node_modules

【讨论】:

    【解决方案3】:

    当您从 node-modules 文件夹中删除包或您在 package.json 中错误地声明了 react-native-firebase 时,可能会发生这种情况。 解决这个问题:

    1. package.json 文件中删除 react-native-firebase
    2. node-modules 中删除 react-native-firebase 包(如果您想保持节点模块包清晰)。
    3. 再次重新安装您的依赖项:

    npm I react-native-firebase

    .

    确保您的节点模块文件夹中没有具有相同规则的重复包。

    【讨论】:

      猜你喜欢
      • 2018-09-02
      • 2022-08-14
      • 2022-10-01
      • 2019-01-13
      • 1970-01-01
      • 2023-02-06
      • 2019-08-26
      • 1970-01-01
      • 2019-04-01
      相关资源
      最近更新 更多