8
votes

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

1

1 Answers

4
votes

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