简体   繁体   English

无法运行程序“adb”:错误=13,权限被拒绝

[英]Cannot run program "adb": error=13, Permission denied

I have a program, which must execute only one command我有一个程序,它必须只执行一个命令

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        Runtime.getRuntime().exec("adb shell input tap 0 0")
    }
}

But I'm getting an error但我收到一个错误

Process: com.example.tomfo.pokerclicker, PID: 11578
java.io.IOException: Cannot run program "adb": error=13, Permission denied
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
    at java.lang.Runtime.exec(Runtime.java:695)
    at java.lang.Runtime.exec(Runtime.java:525)
    at java.lang.Runtime.exec(Runtime.java:422)
    at com.example.tomfo.pokerclicker.MainActivity$onCreate$1.run(MainActivity.kt:14)
    at java.util.TimerThread.mainLoop(Timer.java:562)
    at java.util.TimerThread.run(Timer.java:512)
 Caused by: java.io.IOException: error=13, Permission denied
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
    at java.lang.ProcessImpl.start(ProcessImpl.java:132)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    at java.lang.Runtime.exec(Runtime.java:695) 
    at java.lang.Runtime.exec(Runtime.java:525) 
    at java.lang.Runtime.exec(Runtime.java:422) 
    at com.example.tomfo.pokerclicker.MainActivity$onCreate$1.run(MainActivity.kt:14) 
    at java.util.TimerThread.mainLoop(Timer.java:562) 
    at java.util.TimerThread.run(Timer.java:512) 

Although I've added adb to path into properties on Windows and can run abd commands throw Android Studio console (but in Android Studio console command is not green).虽然我已经将 adb 添加到 Windows 上的属性中,并且可以运行 abd 命令 throw Android Studio 控制台(但在 Android Studio 控制台中命令不是绿色的)。 How to solve this problem?如何解决这个问题呢? This command is working throw Studio console command此命令正在运行 throw Studio 控制台命令

adb is a tool you use on your computer, "adb shell" opens a shell on the device (or emulator), and "adb shell command" runs the command on it. adb 是您在计算机上使用的工具,“adb shell”在设备(或模拟器)上打开一个 shell,“adb shell command”在其上运行命令。

So if you want to run the command programmatically on the device, just remove "adb shell":因此,如果您想在设备上以编程方式运行命令,只需删除“adb shell”:

Runtime.getRuntime().exec("input tap 0 0")

I got it like this我得到它是这样的

 fun commandAdb() {
    InstrumentationRegistry.getInstrumentation().uiAutomation.executeShellCommand("svc wifi disable")
    InstrumentationRegistry.getInstrumentation().uiAutomation.executeShellCommand("svc data disable")
}

暂无
暂无

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

相关问题 无法运行程序“... / abc.exe”:错误= 13,权限被拒绝 - Cannot run program “…/abc.exe”: error=13, Permission denied 使用sql loader加载数据时出错。 无法运行程序“sqlldr”:error = 13,权限被拒绝 - Error while loading data using sql loader. Cannot run program “sqlldr”: error=13, Permission denied 无法运行程序“/Applications/Utilities/Terminal.app”:错误= 13,权限被拒绝 - Cannot run program “/Applications/Utilities/Terminal.app”: error=13, Permission denied IntelliJ 说&#39;无法运行程序&#39;/path/to/tomcat/bin/catalina.sh&#39;错误=13 权限被拒绝 - IntelliJ says 'cannot run program '/path/to/tomcat/bin/catalina.sh' error=13 permission denied W/System.err:java.io.IOException:无法运行程序“python”:错误=13,权限被拒绝 - W/System.err: java.io.IOException: Cannot run program "python": error=13, Permission denied 通过java程序在IBM云中运行shell命令,将抛出java.io.IOException错误:无法运行program = 13,权限被拒绝 - Running a shell command in IBM cloud through java programme throwing error as java.io.IOException: Cannot run program =13, Permission denied 无法运行程序“ /home/pi/SPI-Py/MFRC522-python/Read.py”:错误= 13,权限被拒绝 - Cannot run program “/home/pi/SPI-Py/MFRC522-python/Read.py”: error=13, Permission denied 从Java程序运行时ADB权限被拒绝 - Adb permission denied when run from Java program 无法运行程序,权限被拒绝erro13 Jenkins - Can not run program, permission denied erro13 Jenkins java.io.IOException:无法运行程序adb.exe CreateProcess error = 5,拒绝访问 - java.io.IOException: Cannot run program adb.exe CreateProcess error=5, Access is denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM