博览会退出后:在根项目“ android”中找不到任务“ installDebug”

时间:2019-04-29 19:36:52

标签: android react-native react-native-android expo

我想构建我的应用程序而不在Expo服务器上发送源代码。

因此,我使用ExpoKit弹出了Expo的应用程序。

我使用命令expo eject,结果成功。

我使用react-native run-android启动该应用,但出现错误。通过将gradlew.bat添加到目录android解决了该问题。默认情况下,expo eject中缺少它。

所以我再次启动应用程序,开始构建,但是又遇到第二个错误:

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' not found in root project 'android'.

* Try:
Run gradlew tasks to get a list of available tasks. 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

在目录android中,我使用此命令gradlew tasks,我已经知道了:

...
Install tasks
-------------
installDevKernelDebug - Installs the DebugDevKernel build.
installDevKernelDebugAndroidTest - Installs the android (on device) tests for the DevKernelDebug build.
installProdKernelDebug - Installs the DebugProdKernel build.
installProdKernelDebugAndroidTest - Installs the android (on device) tests for the ProdKernelDebug build.
uninstallAll - Uninstall all applications.
uninstallDevKernelDebug - Uninstalls the DebugDevKernel build.
uninstallDevKernelDebugAndroidTest - Uninstalls the android (on device) tests for the DevKernelDebug build.
uninstallDevKernelRelease - Uninstalls the ReleaseDevKernel build.
uninstallProdKernelDebug - Uninstalls the DebugProdKernel build.
uninstallProdKernelDebugAndroidTest - Uninstalls the android (on device) tests for the ProdKernelDebug build.
uninstallProdKernelRelease - Uninstalls the ReleaseProdKernel build.
...

当我创建一个本机应用程序时,我没有这个问题。

Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.

除了最后一行Build成功或其他错误,这意味着我已解锁,我除此以外!

1 个答案:

答案 0 :(得分:0)

我解决了我的问题。

第1步:

请勿使用react-native run-android

第2步:

从另一个本机项目中复制文件gradlew.bat

第3步:

在目录/android中执行命令gradlew tasks

检查可以在Install tasks中使用的命令

Install tasks
-------------
installDevKernelDebug - Installs the DebugDevKernel build.
installDevKernelDebugAndroidTest - Installs the android (on device) tests for the DevKernelDebug build.
installProdKernelDebug - Installs the DebugProdKernel build.
installProdKernelDebugAndroidTest - Installs the android (on device) tests for the ProdKernelDebug build.
uninstallAll - Uninstall all applications.
uninstallDevKernelDebug - Uninstalls the DebugDevKernel build.
uninstallDevKernelDebugAndroidTest - Uninstalls the android (on device) tests for the DevKernelDebug build.
uninstallDevKernelRelease - Uninstalls the ReleaseDevKernel build.
uninstallProdKernelDebug - Uninstalls the DebugProdKernel build.
uninstallProdKernelDebugAndroidTest - Uninstalls the android (on device) tests for the ProdKernelDebug build.
uninstallProdKernelRelease - Uninstalls the ReleaseProdKernel build.

使用命令gradlew installDevKernelDebug

该应用程序将安装在移动设备上。

第4步:

进入根目录和expo start。 在浏览器中,转到http://localhost:19002。 选择本地连接并恢复值,例如 expXXXXXXXXXXXXXXXXXXX://127.0.0.1:19000

检查<NameProject>\android\app\src\main\java\host\exp\exponent\generated\DetachBuildConstants.java上的文件,然后将值复制到DEVELOPMENT_URL变量中。

第5步:

使用控制台上的CTRL+C退出Metro Bundler。 在Android目录中使用gradlew installDevKernelDebug。 构建完成后,进入根目录并使用expo start

要完成在设备上启动应用程序。

Voila!

相关问题