React Native – 添加 react-native-firebase 后,Android 编译失败。

huangapple go评论93阅读模式
英文:

React Native - android wont compile after adding react-native-firebase

问题

我的React Native Android在根据文档添加react-native-firebase后编译正常(iOS编译正常)。以下是相关信息:

  • React Native版本为0.63.2,react-native-firebase版本为8.3.0(最新版本)。
  • 我非常仔细地按照文档进行了操作。我的操作系统是OSX 10.15.6。
  • 我已删除/清除/重新安装了gradle和android gradle/build文件夹等。
  • 我的Java JRE版本为8.202,路径为/Library/Internet Plug-Ins/JavaAppletPlugin.plugin
  • 我的Java JRE版本为8.202,路径为/Library/Java/JavaVirtualMachines
  • 请注意,我的JAVA_HOME路径已设置为/Applications/AndroidStudio.app/Contents/jre/jd/Contents/Home

错误信息如下:

> Task :react-native-firebase_app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-firebase_app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
英文:

My react native android was compiling fine until I added react-native-firebase as per the docs (ios compiles fine).

  • React Native 0.63.2 and react-native-firebase 8.3.0 latest versions
    and followed docs very carefully. OSX 10.15.6
  • Deleted/cleared/reinstalled gradle and android gradle/build dirs etc.
  • java JRE v8.202 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
  • java JRE v8.202 /Library/Java/JavaVirtualMachines
  • Note that JAVA_HOME path set to /Applications/AndroidStudio.app/Contents/jre/jd/Contents/Home

Error:

> Task :react-native-firebase_app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-firebase_app:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

答案1

得分: 11

我正在使用Mac Bigsur beta 4,并且遇到了相同的问题。

我尝试按照此链接中的步骤卸载Java:
> https://www.java.com/en/download/help/mac_uninstall_java.xml

之后,我在终端中使用以下命令检查了Java版本:java -version
卸载过程没有成功。然而,现在运行react-native run-android可以工作。

尝试这个。可能对你有用。

注意:如果你尝试卸载Java,运行react-native run-android仍然不起作用,将以下内容添加到bash_profile,然后再试一次:export JAVA_HOME=/Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home

英文:

I'm using Mac Bigsur beta 4, and I have the same problem.

I tried uninstalling java by following the steps in this link:

> https://www.java.com/en/download/help/mac_uninstall_java.xml

After that I checked the java version in terminal using: java -version.
The uninstall process didn't work. However, running react-native run-android now works.

Try this. It may work for you.

Note: If you tried uninstalling java, and running react-native run-android still doesn't work, add this to bash_profile and try again: export JAVA_HOME=/Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home

答案2

得分: 3

已运行 source ~/.bash_profile 以确保 JAVA_HOME 路径设置为 /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home,并成功编译,好极了。

英文:

Ran source ~/.bash_profile to ensure JAVA_HOME path set to /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home and it compiled, yay.

huangapple
  • 本文由 发表于 2020年8月6日 14:47:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/63278221.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定