我想构建一个本机模块来对重启设备进行本机反应。我发现这个在java中以编程方式关闭设备。它在 android studio 中单独工作,但是当我尝试在本机模块中使用它时,出现以下错误
https://pasteboard.co/IztJ6ll.jpg
C:\Users\Ali\Desktop\Android\ReactNative\ReactNativeTest\android\app\src\main\ja
va\com\reactnativetest\ToastModule.java:42: error: unreported exception IOExcept
ion; must be caught or declared to be thrown
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "reboot"
});
^
C:\Users\Ali\Desktop\Android\ReactNative\ReactNativeTest\android\app\src\main\ja
va\com\reactnativetest\ToastModule.java:43: error: unreported exception Interrup
tedException; must be caught or declared to be thrown
proc.waitFor();
^
2 errors
> Task :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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 9s
57 actionable tasks: 1 executed, 56 up-to-date
error 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
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag
for more details.
慕斯709654
相关分类