我有我的"Helloworld“应用程序的模板代码,它是用javascript和编写的。我连接了我的android仿真器,想在上面启动这个应用程序。当我运行“react本机运行-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)
-Concerning是否连接仿真器:
$ adb devices
List of devices attached
emulator-5554 device
(类似于我的Android智能手机)。启用USB调试。
-Concerning我试图解决这个问题的方法:
-I在local.properties文件中指定了sdk.dir的路径
-My操作系统是Windows8.1。格拉德尔的版本是4.7。
-I已经安装了Android、JDK8和11。
-I正在为终端目的使用GitBash。
-I具有以下系统的环境变量:
ANDROID_HOME =c:\User\User\AppData\Local\Sdk
C:\Users\User.gradle\wrapper\dists\gradle-4.7-all\4cret0dgl5o3b21weaoncl7ys\gradle-4.7 = GRADLE_HOME
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_201
Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program路径= C:\Program (X86)\公用文件(x86)\NVIDIA \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,然后它在我的智能手机上启动了这个应用程序。但是,当我向App.js引入一些小的更改时,由于一些未知的错误,项目无法更新,并且无法作为一个新项目重新打开它。所以我不得不通过终端使用“react原生运行-android”来解决这个问题,而现在我正处于这个问题的状态。
发布于 2019-01-30 12:04:49
嗯..。当您在控制台上运行react(本机运行) android时,1它应该检查你是否有android,第二,它应该编译一些东西,第三,它应该在另一个控制台中启动metro bundler。“加载依赖关系图,完成”应该出现在另一个控制台上,而主控制台仍将编译大约一分钟甚至更长时间.然后它将启动意图并打开应用程序。有时,它只是在第一次加载之后显示一个空白屏幕,所以您应该退出应用程序并从新版本中删除它,然后重新打开应用程序。
发布屏幕截图时,您似乎只看到了辅助控制台,而主控制台却没有显示(?)
发布于 2019-01-30 12:05:09
您想要运行一个您必须使用过Android的本机或纯java应用程序吗?
如果是工作室应用程序:您必须从您的手机中启用开发人员的选项,以启用该应用程序,检查如下:
https://stackoverflow.com/questions/54448467
复制相似问题