简体   繁体   中英

Can't build React Native after add React-Native-Camera and React-Native-Push-Notification

My existing project was working fine with

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

After I added "react-native-push-notification" to my project =>

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

I encountered several issues, and I fixed them one by one and after add

android.enableJetifier=true
android.useAndroidX=true

to the gradle.properties I ended up with an issue in React-Native-Camera

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

I doubt the error occurred because of some version mismatches, but I couldn't find it. Can someone help me to resolve this issue?

On MacOSX bigsur, for me the problem was really that I had 2 JDK's installed:

$ /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 needs the adoptopenjdk version, so I added to my ~/.bash_profile the adoptopenjdk path as the JAVA_HOME environment variable:

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM