Task 'apkcopy' not found in root project

来源:7-9 gradle执行外部命令实战

周康武

2018-11-20

执行gradlew apkcopy 命令的结果

FAILURE: Build failed with an exception.

* What went wrong:
Task 'apkcopy' not found in root project 'CongBao'.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace opt
ion to get the stack trace. Run with --info or --debug option to get more log
 output. Run with --scan to get full insights.

为什么?

写回答

1回答

周康武

提问者

2018-11-20

```

task('apkcopy'){
   doLast {
       def sourcePath = this.buildDir.path + '/outputs/apk'
       def destination = 'E:/私人文档/youbaoProject/'
       def command = "mv -f ${sourcePath} ${destination}"
       exec {//执行外部命令
           try {
               executable 'bash'
               args '-c', command
               println 'the command is execute success'
           } catch (GradleException e) {
               println 'the command is execute failed'
           }
       }
   }
}

```

把 task(name: 'apkcopy') 改成 task('apkcopy') 可以执行,但是报下面这个错误

```

* What went wrong:

Execution failed for task ':app:apkcopy'.

> A problem occurred starting process 'command 'bash''

```

请问是不是 win 平台下不能执行“mv” 命令?

0
4
慕粉15633829639
回复
qndroid
在windows里面这条命令压根不能用,不说别的,路径根本调不出来。
2021-10-04
共4条回复

Gradle3.0自动化项目构建技术精讲+企业级案例实操

全面覆盖Gradle核心知识和高级用法,高级工程师必备技能!

877 学习 · 144 问题

查看课程