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?
Variable name: ANDROID_HOME , Variable value: the path where you installed the android SDK, in my case is, C:\Android\android-sdk . You have to add the variable to the Path variable system by adding this: ;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools; .
It provides access to the Android file system and allows you to run Android applications from the command line. The Android shell is based on the Linux shell and provides many of the same commands. However, there are some important differences. The Android shell is not a full-fledged Linux environment.
To use it in your shell, you can add it to your .profile file: Please open a fresh terminal window after you did that, or load the changes by typing this in your terminal: Show activity on this post. Once you have Android Studio set up make sure you can connect to an emulator or a device where it will be listed in the AVD (Android Virtual Devices).
It's possible to add to PATH in Windows and use Terminal inside Android Studio only by command: adb shell and after use su get root shell. Older Windows will maybe need to reboot after changing the PATH variables.
But on top of that, the PATH will be different in different contexts. For example, open the Script Editor application, make a new script document, enter do shell script "echo $PATH" and run the script by hitting the run/play button. The small AppleScript we just built runs the shell command echo from the AppleScript context.
1 Access the terminal at the bottom of the IDE by selecting the Terminal button. 2 In the terminal issue adb devices. This will list the all devices currently connected to Android Studio. Find and use your device's name for step 3. 3 Now issue adb -s <device-name> shell. Now you are in your device's shell.
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:
Output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With