2016-03-23 157 views
4

我成功地設置了反應,在Windows上創建新的應用程序在android上。但是當我嘗試在模擬器中運行應用程序時,我陷入了下面提到的錯誤。任何人都可以幫我解決這個問題嗎? 在此先感謝...應用程序:compileDebugJavaWithJavac失敗

>react-native run-android 

'which' is not recognized as an internal or external command, 
operable program or batch file. 
Starting JS server... 
Starting the packager in a new window is not supported on Windows yet. 
Please start it manually using 'react-native start'. 
We believe the best Windows support will come from a community of people 
using React Native on Windows on a daily basis. 
Would you be up for sending a pull request? 
Building and installing the app on the device (cd android && gradlew.bat 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:prepareComAndroidSupportSupportV42301Library UP-TO-DATE 
:app:prepareComFacebookFrescoDrawee081Library UP-TO-DATE 
:app:prepareComFacebookFrescoFbcore081Library UP-TO-DATE 
:app:prepareComFacebookFrescoFresco081Library UP-TO-DATE 
:app:prepareComFacebookFrescoImagepipeline081Library UP-TO-DATE 
:app:prepareComFacebookFrescoImagepipelineOkhttp081Library UP-TO-DATE 
:app:prepareComFacebookReactReactNative0222Library 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 
+0

請參閱http://stackoverflow.com/questions/11345193/gradle-does-not-find-tools-jar –

+1

如果有人因爲更改項目名稱而導致此問題,請檢查'project/android/app/src/main/java/com「作爲舊名稱的文件夾並將其刪除(只要正確的重命名文件夾也存在)。 – rosendin

回答

0

啓動JS服務器... 開始在新窗口中打包器不支持Windows呢。 請使用'react-native start'手動啓動它。

您是否曾嘗試在單獨的cmd窗口中運行此命令?

要清楚,在運行命令時,您應該位於RN應用程序的根目錄中。

4

我遇到了同樣的問題。您需要設置JAVA_HOME環境變量。要做到這一點:

  1. 按Ctrl + Alt鍵+Ť打開你的終端。
  2. 輸入以下命令:$ subl /etc/environment
  3. 根據您安裝Java的位置,您需要提供完整路徑。在這個例子中,我在/usr/lib/jvm/jdk1.7.0_79目錄中安裝了JDK 1.7。滾動到文件的末尾,輸入以下命令:

    JAVA_HOME="/usr/lib/jvm/jdk1.7.0_79" export JAVA_HOME

  4. 保存文件並退出崇高。
  5. 最後,使用以下命令重新加載系統PATH:$ . /etc/environment

這應該解決您的問題。

+0

謝謝。在我的工作。 – nrgwsth

-3
react-native upgrade 

適合我。

相關問題