执行任务“:React Native防火墙:编译调试JavaWithJavac”失败

busg9geu  于 2023-01-09  发布在  React
关注(0)|答案(7)|浏览(113)

在我的React Native 0.60.4应用程序中,我尝试使用react-native-firebase,但除了react-native-link之外,我已经完成了所有操作,因为最新版本的React Native不支持x1m2 n1 a。当我给予命令react-native-run-android时,它显示了来自react-native-firebase节点模块的许多错误。我猜这是由于某些版本冲突而发生的。下面是长错误:

以下是我的应用构建/gradle文件依赖关系:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+" 
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-firestore:19.0.0"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    // implementation "com.google.firebase:firebase-functions: 17.0.0"
    // implementation "com.google.firebase:firebase-analytics: 16.5.0"
    // implementation " com.google.firebase:firebase-ads:17.2.1"
    // implementation "com.google.android.gms:play-services-measurement-api:16.5.0"
    // implementation "com.google.firebase:firebase-invites:17.0.0"
    // implementation "com.google.firebase:firebase-iid: 18.0.0"
    // implementation "com.google.firebase:firebase-config:17.0.0"
    // implementation "com.google.firebase:firebase-perf:17.0.0"
  
  // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation"com.google.android.gms:play-services-gcm:16.1.0"
   
    implementation 'com.android.support:multidex:1.0.3'

    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'

和我的Android版本/升级:

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "16.1.0" 
        multiDexEnabled = true
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:3.4.2')
        classpath( 'com.google.gms:google-services:4.2.0')

    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven {
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            url("$rootDir/../node_modules/jsc-android/dist")
        }

    }
}
qaxu7uf2

qaxu7uf21#

运行npx jetify
从项目根目录,其中node_modules是

yws3nbqq

yws3nbqq2#

只需重新安装***React Native Firebase***

npm install --save @react-native-firebase/app

在此之后,它100%工作。

k4emjkb1

k4emjkb13#

你已经用这个更新了你的openjdk:

brew tap homebrew/cask-versions
brew install --cask zulu11
zqdjd7g9

zqdjd7g94#

我也刚刚面临过这个问题。将openjdk从8升级到11将会消 debugging 误。
This script is to install openjdk 11: https://github.com/invertase/react-native-firebase/issues/1988#issuecomment-1070831039.

hmtdttj4

hmtdttj45#

对我来说,问题@react-native-firebase/app@react-native-firebase/firestore版本之间的差异,因此重新安装库将它们都更新到最新版本,问题得到了解决

yarn add @react-native-firebase/app @react-native-firebase/firestore
OR 
npm install @react-native-firebase/app @react-native-firebase/firestore
qxsslcnc

qxsslcnc6#

尽管它说这里firebase有问题,但是将JDK更新到JDK 11可以解决这个问题。
请务必使用SDK man管理同一台计算机上的不同Java版本。

相关问题