简体   繁体   English

向RootTools v4.2 shell添加命令时,Android应用程序崩溃

[英]Android app crashes when adding commands to RootTools v4.2 shell

I have an Android application utilizing RootTools v4.2 (the latest I know of) and I have followed their documentation on how to execute shell commands as root. 我有一个Android应用程序利用RootTools v4.2(我知道的最新),我已经按照他们的文档介绍了如何以root身份执行shell命令。 Sometimes the commands execute just fine, other times the app crashes with the following exception. 有时命令执行得很好,有时应用程序崩溃时会出现以下异常。

java.lang.IllegalStateException: Unable to add commands to a closed shell

Here is the actual code the exception is being throw on: 以下是异常的实际代码:

RootTools.getShell(true).add(cmd);

So I'm wondering since the docs make no mention of this sort of problem if there is something else I'm doing wrong? 所以我想知道,因为如果还有别的东西我做错了,那么文档就没有提到这类问题? Looking through the docs I see nothing on how to ensure I get an open shell before I start adding commands. 通过文档查看,在开始添加命令之前,我没有看到如何确保打开shell。

This code is working with me . 此代码正在与我合作。 Try to install the Library again may be its not vaild . 尝试再次安装库可能不是它的vaild。

if(RootTools.isAccessGiven()){
try {
    Shell shell = RootTools.getShell(true);
    JavaCommand cmd = new JavaCommand(0,this,"input keyevent 26");
    shell.add(cmd);
}
catch (Exception e){
    Log.d("ERRORS : ",e.getMessage());
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Android Studio v4.2 中解决 `java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException` - How to resolve `java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException` in Android Studio v4.2 如何使用Android版Facebook SDK v4.2获取用户详细信息 - How to get user details using Facebook SDK v4.2 for android 有效载荷大小从 BLE v4.2 到 4.0 的向后兼容性 - Backward compatibility on payload size from BLE v4.2 to 4.0 添加 firebase crashlytics 时,Android 应用程序崩溃 - Android app crashes when adding firebase crashlytics facebook sdk v4.2显示错误,导致类com.facebook.login.widget.LoginButton膨胀 - facebook sdk v4.2 shows Error inflating class com.facebook.login.widget.LoginButton 添加Facebook登录按钮时Android App崩溃 - Android App crashes when adding Facebook login button Android Lollipop:在将Home小部件添加到主屏幕时,Launcher崩溃了 - Android Lollipop: Launcher crashes when adding app widget to Home Screen 添加Google地图标记时,Android应用程序崩溃 - Android app crashes when adding Google map markers 添加TextChangedListener时应用崩溃 - App crashes when adding TextChangedListener 添加ImageView时应用崩溃 - App crashes when adding an ImageView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM