Android Studio升级到4.1.1之后通过面板打开Terminal 失败,提示Cannot open 本地Failed to start [powershell.exe, -NoExit, -ExecutionPolicy, Bypass, -File,C:…
查阅:Android Studio终端:有关详细信息,请查看 IDE 日志(帮助 | 在 文件资源管理器 中显示日志)。_android studiocannot open 本地 failed to start [powe-CSDN博客中提到的方法逐一进行验证
1.检查管理的shell 、cmd路径都正确,且在文件夹点击对应的exe能正常启动窗口,但在AS中无法启动
2.使用管理员权限启动AS,打开Terminal面板仍然失败
3.该问题与Android SDK无关
百度搜索了一圈也没有发现可以解决问题的办法,回到窗口提示,通过help->show log in Explorer,检查具体的日志,打开idea.log文件,找到can not open这里,如下:
2024-08-23 16:42:16,897 [ 103446] INFO - #o.j.p.t.AbstractTerminalRunner - Cannot open Local
java.util.concurrent.ExecutionException: Failed to start [C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe, -NoExit, -ExecutionPolicy, Bypass, -File, D:\Program Files\Android\Android Studio\plugins\terminal\shell-integrations\powershell\powershell-integration.ps1] in E:\xxx\xxxx, [columns=224, rows=18], envs={CommonProgramFiles=>C:\Program Files\Common Files, IntelliJ IDEA=>d:\Program Files\JetBrains\IntelliJ IDEA 2019.3.3\bin;, FPS_BROWSER_USER_PROFILE_STRING=>Default, GRADLE_5.5_HOME=>C:\Users\xxxxx\.gradle\wrapper\dists\gradle-7.0.2-bin\857tjihv64xamwrf0h14cai3r\gradle-7.0.2, ProgramData=>C:\ProgramData, COMPUTERNAME=>DESKTOP-6721SGM, SystemDrive=>C:, USERDOMAIN=>DESKTOP-6721SGM, OneDrive=>C:\Users\xxxxxx\OneDrive, CommonProgramFiles(x86)=>C:\Program Files (x86)\Common Files, TMP=>C:\Users\xxxx\AppData\Local\Temp, TEMP=>C:\Users\xxxx\AppData\Local\Temp, VBOX_MSI_INSTALL_PATH=>D:\Program Files\Oracle\VirtualBox\, ProgramFiles=>C:\Program Files, USERDOMAIN_ROAMINGPROFILE=>DESKTOP-6721SGM, windir=>C:\Windows, PROCESSOR_LEVEL=>6, ComSpec=>C:\Windows\system32\cmd.exe, JAVA_HOME=>D:\Program Files\Java\jdk-12.0.1, NUMBER_OF_PROCESSORS=>8, PROCESSOR_ARCHITECTURE=>AMD64, OS=>Windows_NT, JETBRAINS_INTELLIJ_COMMAND_END_MARKER=>9kpKxf4LhU4IHS25Chvnq2v2gdLMq2e5sGg1LEWGYlwss4fzXBD4xPwUWL75QX5h, ANDROID_HOME=>E:\Android\Sdk, ProgramFiles(x86)=>C:\Program Files (x86), PSModulePath=>C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules, PATHEXT=>.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC, PROCESSOR_IDENTIFIER=>Intel64 Family 6 Model 94 Stepping 3, GenuineIntel, APPDATA=>C:\Users\xxx\AppData\Roaming, WXDRIVE_START_ARGS=>--wxdrive-setting=0 --disable-gpu --disable-software-rasterizer --enable-features=NetworkServiceInProcess, LOCALAPPDATA=>C:\Users\xxxx\AppData\Local, WebStorm=>d:\Program Files\JetBrains\WStorm2020.1\bin;, SystemRoot=>C:\Windows, HOMEPATH=>\Users\westone, TERMINAL_EMULATOR=>JetBrains-JediTerm, LOGONSERVER=>\\DESKTOP-6721SGM, SESSIONNAME=>Console, HOMEDRIVE=>C:, ANDROID_SDK_HOME=>E:\Android\Sdk, MAVEN_HOME=>D:\apache-maven-3.6.3-bin\apache-maven-3.6.3, Path=>C:\Program Files (x86)\Westone\DLP-Client\x64\x64;C:\Program Files (x86)\Westone\DLP-Client\x64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files\Android\Android Studio\jre\bin;D:\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin;D:\node-v12.16.2-win-x64;D:\Program Files\Java\jdk-12.0.1\bin;E:\Android\Sdk\platform-tools;E:\Android\Sdk\;C:\Python27;E:\Android\Sdk\cmake\3.10.2.4988404\bin;D:\Program Files\Git\cmd;C:\Program Files\Redis;D:\mysql-8.0.28-winx64\bin;D:\test_app_code\tools_kit\微信web开发者工具\dll;E:\Android\Ndk\android-ndk-r21;F:\chrominum2024\depot_tools;C:\Users\xxxx\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Android\Android Studio\jre\bin;d:\Program Files\JetBrains\IntelliJ IDEA 2019.3.3\bin;d:\Program Files\JetBrains\WStorm2020.1\bin;E:\Android\Sdk\platform-tools;C:\Users\xxxx\.gradle\wrapper\dists\gradle-7.0.2-bin\857tjihv64xamwrf0h14cai3r\gradle-7.0.2\bin;D:\Program Files\Microsoft VS Code\bin;E:\Android\flutter_sdk\flutter_windows_1.22.6-stable\bin;E:\Android\Ndk\android-ndk-r21;d:\Program Files\Huawei\DevEco Studio\bin;, PUBLIC=>C:\Users\Public, FPS_BROWSER_APP_PROFILE_STRING=>Internet Explorer, DevEco Studio=>d:\Program Files\Huawei\DevEco Studio\bin;, IDEA_INITIAL_DIRECTORY=>C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Android Studio, PROCESSOR_REVISION=>5e03, USERPROFILE=>C:\Users\xxxx, ALLUSERSPROFILE=>C:\ProgramData, USERNAME=>westone, ProgramW6432=>C:\Program Files, CommonProgramW6432=>C:\Program Files\Common Files, TERM_SESSION_ID=>166aa891-efa0-40ef-a2f8-bb491e1f1fcf}
at org.jetbrains.plugins.terminal.LocalTerminalDirectRunner.createProcess(LocalTerminalDirectRunner.java:257)
at org.jetbrains.plugins.terminal.LocalTerminalDirectRunner.createProcess(LocalTerminalDirectRunner.java:58)
at org.jetbrains.plugins.terminal.AbstractTerminalRunner.lambda$openSessionInDirectory$2(AbstractTerminalRunner.java:220)
at com.intellij.openapi.application.impl.RwLockHolder$executeOnPooledThread$1.run(RwLockHolder.kt:154)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: com.pty4j.windows.conpty.LastErrorExceptionEx: UpdateProcThreadAttribute failed: GetLastError() returned 50: 不支持该请求。
at com.pty4j.windows.conpty.ProcessUtils.prepareStartupInformation(ProcessUtils.java:68)
at com.pty4j.windows.conpty.ProcessUtils.startProcess(ProcessUtils.java:24)
at com.pty4j.windows.conpty.WinConPtyProcess.<init>(WinConPtyProcess.java:42)
at com.pty4j.PtyProcessBuilder.start(PtyProcessBuilder.java:139)
at org.jetbrains.plugins.terminal.LocalTerminalDirectRunner.createProcess(LocalTerminalDirectRunner.java:251)
... 12 more
可知是 “com.pty4j.windows.conpty.LastErrorExceptionEx: UpdateProcThreadAttribute failed: GetLastError() returned 50: 不支持该请求” 这里出问题导致的。
百度搜索该错误关键句,找到 Caused by: com.pty4j.windows.conpty.LastErrorExceptionEx: UpdateProcThreadAttribute failed: GetLastE-CSDN博客根据其中提示修改AS 4.1.1的配置文件,增加
-Dcom.pty4j.windows.disable.bundled.conpty=true
保存并重启AS,terminal可以正常打开了。