更新到 Android Studio Bumblebee 后 | 2021.1.1 (Mac OS),gradle exec 插件无法工作。
这是一个带有 exec 的 gradle 任务示例:
task testExec(type: Exec) {
commandLine 'npm', '--version'
}
在 Android Studio 中运行此任务时,出现此错误:
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'npm''
at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:241)
at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:218)
at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:369)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:87)
at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
... 3 more
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.startProcess(ExecHandleRunner.java:98)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:71)
... 4 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/Users/pavel/AndroidStudioProjects/tempexec/app"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 7 more
Caused by: java.io.IOException: error=2, No such file or directory
... 8 more
但是当从控制台 - 运行它时./gradlew app:testExec
,一切正常:
> Task :app:testExec
8.3.1