2016-08-19 148 views
-1

我在Windows 10上運行react-native,我遇到了一堆問題。 首先,在項目的根目錄下,當我運行Windows 10反應原生android問題

react-native run-android 

我得到這個錯誤:

JS server already running. Building and installing the app on the device (cd android && gradlew.bat installDebug... 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

而且隨着--stacktrace --info沒有幫助運行它。 然後我決定做手工運行Android的腳本似乎什麼是試圖通過進入Android的目錄,以實現和運行

cd android && gradlew.bat installDebug 

建立我自認爲,產生了一堆的結果,但在錯誤仍然結束。

:app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). C:\Users\jiangyaokai\workspace\maincourse\android\app\src\main\java\com\maincourse\MainApplication.java:30: error: cannot find symbol new CodePush(this.getResources().getString(R.strings.reactNativeCodePush_androidDeploymentKey), this, BuildConfig.DEBUG), ^ symbol: variable strings location: class R C:\Users\jiangyaokai\workspace\maincourse\android\app\src\main\java\com\maincourse\MainApplication.java:30: error: cannot find symbol new CodePush(this.getResources().getString(R.strings.reactNativeCodePush_androidDeploymentKey), this, BuildConfig.DEBUG), ^ symbol: method getResources()

2 errors :app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details.

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

BUILD FAILED

Total time: 8.109 secs

我在想我在做什麼錯?謝謝。

回答

1

下面是從你的錯誤消息的一個片段:

MainApplication.java:30: error: cannot find symbol new CodePush(this.getResources().getString(R.strings.reactNativeCodePush_androidDeploymentKey), this, BuildConfig.DEBUG),^symbol: method getResources() 

它看起來像它有事情做與CodePush插件,您正在使用。

你能按照這裏的安裝說明:https://github.com/Microsoft/react-native-code-push#android-setup並再試一次。

+0

但它似乎不僅僅是CodePush,R.strings也有問題,如果它只是CodePush,那麼我可以刪除它,但事實並非如此。我只是想知道R.strings如何不被識別。 – user1380898

+1

@ user1380898嘗試'android /'裏面的'gradlew clean'。 –

+0

@Baja對於這個'gradlew clean',不夠感謝。 – Rudy

0

已解決。

符號:變量字符串位置:R級

這是由事實是R只有字符串,但不是字符串,不知道爲什麼代碼(自動生成)是指字符串引起的。

符號:方法getResources()

這是缺少因爲「這」指的是內部類,何在getResources()在外部類只找到。總的來說,基本上代碼是錯誤的,正確的編譯不了。

感謝所有。