我遵循了getting started guide Android/Linux.

我try 使用react-native run-android在ubuntu下启动react native,但失败了,出现了以下错误:

FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Could not find tools.jar  

我该怎么修?

完整输出:

 $ react-native run-android
    Starting JS server...
    /bin/sh: 1: adb: not found
    Building and installing the app on the device (cd android && ./gradlew installDebug...
    :app:preBuild UP-TO-DATE
    :app:preDebugBuild UP-TO-DATE
    :app:checkDebugManifest
    :app:preReleaseBuild UP-TO-DATE
    :app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
    :app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
    :app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE
    :app:prepareComFacebookFrescoDrawee0110Library UP-TO-DATE
    :app:prepareComFacebookFrescoFbcore0110Library UP-TO-DATE
    :app:prepareComFacebookFrescoFresco0110Library UP-TO-DATE
    :app:prepareComFacebookFrescoImagepipeline0110Library UP-TO-DATE
    :app:prepareComFacebookFrescoImagepipelineBase0110Library UP-TO-DATE
    :app:prepareComFacebookFrescoImagepipelineOkhttp30110Library UP-TO-DATE
    :app:prepareComFacebookReactReactNative0361Library UP-TO-DATE
    :app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE
    :app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE
    :app:prepareDebugDependencies
    :app:compileDebugAidl UP-TO-DATE
    :app:compileDebugRenderscript UP-TO-DATE
    :app:generateDebugBuildConfig UP-TO-DATE
    :app:generateDebugAssets UP-TO-DATE
    :app:mergeDebugAssets UP-TO-DATE
    :app:generateDebugResValues UP-TO-DATE
    :app:generateDebugResources UP-TO-DATE
    :app:mergeDebugResources UP-TO-DATE
    :app:bundleDebugJsAndAssets SKIPPED
    :app:processDebugManifest UP-TO-DATE
    :app:processDebugResources UP-TO-DATE
    :app:generateDebugSources UP-TO-DATE
    :app:processDebugJavaRes UP-TO-DATE
    :app:compileDebugJavaWithJavac FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Could not find tools.jar

echo $JAVA_HOME等于/usr/lib/jvm/java-8-openjdk-amd64

推荐答案

通过再次安装openjdk解决了这个问题:

sudo apt-get install openjdk-8-jdk

React-native相关问答推荐

如何在Reaction本地日历中 Select 年份?

如何在使用嵌套的堆栈导航器在选项卡之间导航后弹出到堆栈顶部?

Reaction-Native-pdf文件不是PDF格式或已损坏

我们如何才能将我们自己的应用程序(IOS)排除在共享表中?

React Native - remount / reset / reload屏幕的最佳方式是什么?

React Native React 导航标题按钮事件

我可以在状态内有一个函数来响应吗?

React.js - 为所有组件方法使用属性初始化器

如何在 React Native 中创建和保存 CSV 文件?

React Native 用于低互联网带宽的小型 apk APP应用

如何将抖动动画添加到视图(react-native)?

React Native:双击退出应用程序

FlatList contentContainerStyle -> justifyContent: 'center' 导致滚动问题

我可以在 react-native 中使用 reactJS 库吗?

如何在 React Native 中按住以 Select 文本

在 OPTIONS 响应后使 fetch API 与 CORS 一起工作

React Navigation 中的选项卡导航器图标

在不使用 3rd 方库的情况下,在react-native中显示主屏幕之前显示启动画面

NavigationActions.reset 不是函数吗?

如何在 React Native 中强制禁用 iOS 暗模式