How to launch Android Studio from terminal on Windows (and Linux)? - linux

I'm struggling to understand how to open applications from shell.
When I use Atom, I can just run
$ atom .
command to open it in the current directory, but I don't know how to do it with Android Studio.
I don't know if it has something to do with aliases, environment variables or something else, but I'd like to know how this stuff works. I'd also appreciate a short comparison of the same problem on Linux.

On my winslow-7 machine there is an icon on the desktop named "Android studio".
I checked the properties of this icon, and in the destination field I've found:
"C:\Program Files\Android\Android Studio\bin\studio64.exe"
If I type that in a command prompt, Android studio opens normally.
A similar thing works in Linux too.
Basically, to run a program, you have to know where its executable resides; then you can ask the shell to run that executable. A few directories are searched automatically by the system and, if the executable resides in one of those directories, there is no need to indicate the full path - the name of the file suffices. The list of directories is an environment variable, PATH, for both windows and Linux.
This is a short and incomplete answer, though; your question asks a comparison and/or something more, but it is not clear and there would be a lot to say.

If you use the studio64 . command, your current folder will open in android studio.
This works if you've added the path of the bin directory of the android studio installation folder to environment variables. In my case, it is C:\Program Files\Android\Android Studio\bin.
This works the same as atom . or code .(VSCode)
The problem is, that it returns a bunch of warnings and stuff in the terminal before launching android studio. Also, if you close the terminal, the studio crashes.
It works but it's not purrfect.

For Windows:
Make a shortcut for your application and place in C:\WINDOWS\System32
you will be able to call it by the name of the shortcut.
For Linux:
echo $PATH

Related

How to use the kotlin compiler in command line which comes with Android Studio?

I have Android studio version 3.4.1. I am able to build Android apps with the Kotlin language. I have heard that we can use Kotlin for creating standalone programs other than building android apps.
So, I want to know how to run the Kotlin compiler of Android studio to compile and run Kotlin programs in the command line, without downloading anything else?. I am using Windows 10 Pro.
I'm on Lubuntu 16.04 LTS, not Windows. But maybe this can still help you.
In my Lubuntu, Android Studio put the Kotlin compiler in directory
$HOME/.AndroidStudio3.4/config/plugins/Kotlin/kotlinc/bin .
So on Windows, make your file manager show hidden files and directories - because on Lubuntu, the "." in ".AndroidStudio3.4" means "hidden".
Go to your home or user directory and find a directory named "AndroidStudio3.4" or similar. Then just follow the path given above.
On Lubuntu, kotlinc (the compiler) isn't executable. If it's the same on Windows, give it execution permission.
I can't imagine that giving this permission affects how Kotlin works in Android Studio. But if you want to be on the safe side, install a separate command line compiler or IntelliJ.
By the way, the Kotlin 1.3.40 REPL crashes (s. issue KT-32085). If you need it, use Kotlin 1.3.31 .

How do I install Android Studio 3.5 Canary 12?

I need to install it, and downloaded the file, but it is in ZIP format. Inside the archive there is no install file, only `uninstall. How do I install it?
You don't install the canary builds. They are meant to work alongside the stable versions which are installed.
For Windows, extract to some place like C:\Programs\AndroidStudioCanary and inside the bin there will be an executable file for 64bit version(and also for 32bit). Create a shortcut to the file and you are done.
For Linux, extract to some place like /home/user/AndroidStudioCanary and inside the bin there will be a bash script file studio.sh. After first launch close all projects via File->Close projects but do not close the IDE. Now in the main UI, click the settings cog and add desktop entry to create application shortcut.
Launch the shortcut from applications now.
EDIT:
Canary and stable versions can run along side each other and their settings can be changed independently. For Windows and linux the folder named .AndroidStudio3.6 will contain config for stable version and .AndroidStudioCanary4.0 or similarly named folder will contain config for the canary version. These folders are inside user directory and are hidden. I don't have a mac but assume something similar.
For canary builds, there are no traditional executable files that you use to "install" the IDE.
You can go into the bin folder, then run the studio.exe or studio64.exe file (depending on your platform) to run Android Studio

where is the Android Studio executable

Where is the Android Studio executable file stored in the system?
I have it installed, but have unpinned it from the taskbar, which was the only shortcut I had. Since I can't find it in File Explorer, I can't load it.
I've tried the Start menu search function, and used File Explorer to search the entire install directory. The only thing left I can think of to do is reinstall it, but I don't really want to do that, as it was working fine.
P.S. I wasn't sure if this was more appropriate for SuperUser, since it's not directly coding related, or SO, since I doubt the number of people on SuperUser with the answer.
You can find the executable file in bin folder where the android studio is installed, default location is
Windows
C:\Program Files\Android\Android Studio\bin\studio.exe
There is also studio64.exe in the same directory for 64-bit machines
Linux
path_to\android-studio\bin\studio.sh
In Ubuntu/Gnome make sure you create an application file in
/usr/share/applications/android-studio.desktop
with the following content
[Desktop Entry]
Name=AndroidStudio
Type=Application
Exec=/path/to/android-studio/bin/studio.sh
Terminal=false
Icon=/path/to/android-studio/bin/studio.png
Comment=Android Studio
NoDisplay=false
Categories=Development;IDE;
Name[en]=AndroidStudio
This way you will be able to find Android Studio in the applications list, create desktop shortcuts for Android Studio or add it to the favourites bar.
I don't remember how did I installed Android Studio on my Ubuntu 16.04, but my android studio executable is located as /snap/bin/android-studio.

Setting Android Studio's GRADLE_HOME

I installed Android Studio on Linux Mint 17.2, but when I open up a terminal window and echo $GRADLE_HOME, nothing is set. Should it be set? If it should be, how would I find where it is located so I can manually set it myself?
Thx
The Gradle installed via Android Studio will only be available only within Android Studio. I may be wrong here, since I never used Android Studio. However, if you want Gradle available outside of Android Studio you may have to install manually. Check out the Gradle Documentation. Once you installed set the Gradle home in /etc/environment file (There are several files in which you can set this, but this is my preference since it makes the variable available to all users). Add the installation location to that file. You may choose to install in a different location.
GRADLE_HOME=/usr/local/gradle-2.13
After you add add bin location to PATH variable. Eg:
PATH=...:$GRADLE_HOME/bin
Since you are adding the GRADLE_HOME in /etc/environment file you may have to restart your PC after adding.
The Android Studio zip bundles gradle. After unpacking the zip it is located in android-studio/gradle/gradle-x.x/bin (assuming the unpack directory is android-studio). In my case with Android Studio 3.1 the gradle version was gradle-4.4
so setting GRADLE_HOME to /path/to/unpackdir/gradle/gradle-4.4 should work.
Then add $GRADLE_HOME/bin to your path and you should be set.
You might have to chmod +x gradlew (for example if you use cordova and want to install a plugin)

How to make android NDK work in windows?

I have downloaded android-ndk-r10e & I have also setted path in environment variable as well as NDK path for eclipse. I was able to build and run HelloJni sample app from eclipse, but when I use console to build it says
'ndk' is not recognized as an internal or external command,operable
program or batch file.
I have googled this and have also installed Cygwin even though it's not mentioned in offical google installation instructions(https://developer.android.com/ndk/guides/setup.html) but to no vain.
I have set my path but when I do echo %path% it dosen't show up. How can I use NDK from command lines.
The command you're probably looking for is ndk-build, not ndk.

Resources