【发布时间】:2019-02-05 03:40:33
【问题描述】:
我的“Helloworld”应用程序的模板代码是用 javascript 和 Windows 上的 react-native 编写的。我连接了我的安卓模拟器并想在上面启动应用程序。当我运行“react-native run-android”命令时会发生以下情况。 Node.js 作为一个单独的窗口打开,它写着“加载依赖关系图,完成”。但是,在终端窗口中,出现以下错误消息:
>User helloworld $ 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:
Could not create service of type ScriptPluginFactory using
BuildScopeServices.createScriptPluginFactory().
>Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
>Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
>Get more help at https://help.gradle.org
BUILD FAILED in 1s
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/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (C:\Users\User\helloworld\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
-关于模拟器是否连接:
$ adb devices
List of devices attached
emulator-5554 device
(对我的 Android 智能手机同样适用)。 USB 调试已启用。
-关于我试图解决的问题:
- 我的用户设置为管理员。
-
我有JDK11.0.1版本。我安装了 JDK1.8.0_201,现在它被设置为我的 java 版本。
User helloworld $ java -version java version "1.8.0_201" 我在项目目录中创建了“.gradle”文件夹,以防在访问/创建此类文件夹时出现问题。
-我在local.properties文件中指定了sdk.dir的路径
-我的操作系统是 Windows 8.1。 Gradle 的版本是 4.7。
-我已经安装了 Android Studio、JDK8 和 11。
-我将 GitBash 用于终端目的。
-我有以下系统的环境变量:
ANDROID_HOME = c:\Users\User\AppData\Local\Android\Sdk
GRADLE_HOME = C:\Users\User.gradle\wrapper\dists\gradle-4.7-all\4cret0dgl5o3b21weaoncl7ys\gradle-4.7
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_201
路径 = C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32 ;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files \Git\cmd;.\Plugins;C:\Users\User\AppData\Local\Programs\Python\Python37-32;C:\Program Files\nodejs\;c:\Users\User\AppData\Local\Android\ Sdk\platform-tools;C:\Users\User\AppData\Local\Android\Sdk\platform-tools;%GRADLE_HOME%\bin;%JAVA_HOME%\bin
如果您对之前的问题感兴趣: 我最初的问题是没有显示任何错误,但模拟器上仍然没有启动任何内容。我通过将我的项目的“android”文件夹放入 Android Studio 并在我的智能手机上启动该应用程序来解决这个问题。但是,当我对 App.js 进行小改动时,由于一些未知错误,无法更新项目,并且无法将其作为新项目重新打开。所以我不得不尝试通过终端使用“react-native run-android”来运行应用程序来解决这个问题,现在我处于这种问题状态。
【问题讨论】:
标签: android windows react-native-android