8

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

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
serg3z
  • 1,852
  • 12
  • 28

1 Answers1

4

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

Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68
  • 1
    hmm, an interesting solution, I'll try this if the community does not suggest anything more suitable – serg3z Sep 20 '20 at 18:15
  • 1
    the solution is not very suitable because the script has input parameters and you have to wait for the project configuration – serg3z Sep 24 '20 at 13:51