serg3z
serg3z

Reputation: 1862

How can I set path for my Shell Script in Android Studio?

I want to set Script Path for my script in android project without using a strict path(/User/Documents/MyApp/tools/script.sh) as well as "Working directory".

I know that I can use "External tools" but this solution doesn't work because all project developers will have to import my jar file with "external tools" settings

Can I somehow write this path using $ProjectFileDir$ variables? enter image description here

Upvotes: 9

Views: 1238

Answers (1)

Pavneet_Singh
Pavneet_Singh

Reputation: 37414

As of now, there is no direct way to use these variables in the path values of configurations.

Alternatively, you can create a gradle task in app/gradle file to run your shell scripts:

task runSS {
    doLast{
        exec {
            // chmod u+rwx demo.sh to make file executable
            executable "../demo.sh"
        }
    }
}

// other gradle tasks

Make sure to change the permission of the file to executable by using chmod u+rwx file_name.

Now run the file:

enter image description here

Output:

enter image description here

Upvotes: 5

Related Questions