2017-03-07 72 views
0

我嘗試使用以下命令運行的Android項目:反應原生不能建立運行Android的正確

react-native run-android 

,但它不建立任何東西,打印此消息:

Starting JS server... 
Building and installing the app on the device (cd android && gradlew.bat installDebug)... 

FAILURE: Build failed with an exception. 

* What went wrong: 
A problem occurred configuring project ':app'. 
> Could not download javax.inject.jar (javax.inject:javax.inject:1) 
    > Could not get resource 'https://jcenter.bintray.com/javax/inject/javax.inject/1/javax.inject-1.jar'. 
     > Could not GET 'https://jcenter.bintray.com/javax/inject/javax.inject/1/javax.inject-1.jar'. 
     > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed 
t: connect 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log outpu 

BUILD FAILED 

Total time: 2 mins 17.303 secs 
Could not install the app on the device, read the error above for details. 
Make sure you have an Android emulator running or a device connected and have 
set up your Android development environment: 
https://facebook.github.io/react-native/docs/android-setup.html 

我該如何解決它?

+0

爲什麼你需要java.inject.jar?刪除它,它會解決你的問題? –

+0

我不知道,這是哪裏? –

+0

你可以嘗試使用'./gradlew clean'然後'./gradlew build'並且首先打開你的模擬器'react-native run-android' –

回答

2

正如你所看到的,你需要首先運行你的android模擬器或連接到一個設備。

所以在你的終端 類型:

android avd 

然後創建一個設備,如果你沒有一個,然後啓動它。 如果模擬器已經運行,那麼你可以通過鍵入

react-native run-android