2 years ago

#54762

test-img

Elbo Shindi Pangestu

Create Android App Bundle (.aab) using gradlew outside of root directory

I'm trying build .aab using gradle. Here's the command:

./gradlew bundle

But, if I run the command outside the root project, it causing error. Here's the sample command:

./AndroidProject/gradlew bundle

And here's the error:

FAILURE: Build failed with an exception.

* What went wrong:
Task 'bundle' not found in root project 'Downloads'.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

Environment: Mac OSX

Working directory (pwd): /Users/myusername/Downloads

Why I needed this? I'm trying to automate build bundle using golang.

Here's my golang code:

package main

import (
    "fmt"
    "os/exec"
)

func main() {
    cmd := exec.Command("cd", "AndroidProject", "&&", "./gradlew", "bundle")
    out, err := cmd.CombinedOutput()
    if err != nil {
        fmt.Printf("failed with error: %s\n", err)
    }
    fmt.Printf("succed with output:\n%s\n", string(out))
}

This does not work in golang: cd AndroidProject && ./gradlew bundle

go

gradle

gradlew

0 Answers

Your Answer

Accepted video resources