我关注了
getting started guide Android / Linux.
我尝试使用react-native run-android在ubuntu下启动本机反应,但它失败并出现错误:
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