0

我现有的项目运行良好

"react-native": "0.59.x",
"react-native-camera": "^2.11.2"

在我将“react-native-push-notification”添加到我的项目之后 =>

"react-native": "0.59.x",
"react-native-camera": "^2.11.2",
"react-native-push-notification": "^2.1.0",

我遇到了几个问题,我一一修复并添加后

android.enableJetifier=true
android.useAndroidX=true

gradle.properties我在 React-Native-Camera 中遇到了一个问题

Execution failed for task ':react-native-camera:compileGeneralDebugJavaWithJavac'

我怀疑由于某些版本不匹配而发生错误,但我找不到它。有人可以帮我解决这个问题吗?

4

1 回答 1

0

在 MacOSX bigsur 上,对我来说问题实际上是我安装了 2 个 JDK:

$ /usr/libexec/java_home -V | grep jdk

Matching Java Virtual Machines (2):
    1.8.281.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_282 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

React Native 需要adoptopenjdk 版本,所以我在我的~/.bash_profile 中添加了adoptopenjdk 路径作为JAVA_HOME环境变量:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"
于 2021-03-04T09:46:27.000 回答