Windows 10反应原生android问题

问题描述:

我在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

我在想我在做什么错?谢谢。

下面是从你的错误消息的一个片段:

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

已解决。

符号:变量字符串位置:R级

这是由事实是R只有字符串,但不是字符串,不知道为什么代码(自动生成)是指字符串引起的。

符号:方法getResources()

这是缺少因为“这”指的是内部类,何在getResources()在外部类只找到。总的来说,基本上代码是错误的,正确的编译不了。

感谢所有。