Git in terminal console - Android Studio - Autocomplete - android

Is there any way to make the built in terminal console of Android Studio (3.0 Canary) autocomplete git commands like the new Intellij Idea 2017 does?
-- EDITED
I have installed a clean copy of Intellij Idea 2017.1.4 on Windows 10 and noticed that this functionality is not provided by IntelliJ actually. I'm trying to identify that plugin.
-- EDITED
The solution is just set an external bash terminal and restart Android Studio like #lidkxx pointed out...

Not sure if there's anything out of the box, but maybe try Preferences... -> search for Terminal. There's a shell path field and you can choose your shell to be anything you like. I am using zsh with autosuggestions plugin and autocomplete works like a charm.
Edit: You probably need to restart Android Studio for this change to take effect.

If you love bash & Linux command but forced to use Windows for development, you will love this trick.
The console is colored like on Linux and autocomplete works way better than cmd/ PowerShell.
Requirement: Git installed with git-bash
Open Android Studio, go to File > Settings, open Tools > Terminal
Set “Shell Path” to C:\Program Files\Git\bin\bash.exe

For me, 2017.2 on Mac does not autocomplete anything. Probably you are using different shell there, so you just need to configure Android Studio to use it as well, in Settings - Tools - Terminal.

Maybe its late.
To achieve this in windows you can use Powershell along with posh-git. Here are the steps:
1- In Android Studio -> Settings -> Tools -> Terminal -> set the Shell path to powershell.exe
2- Install posh-git:
1- Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion
2- Verify execution of scripts is allowed with Get-ExecutionPolicy (should be RemoteSigned or Unrestricted). If scripts are not enabled, run PowerShell as Administrator and call Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm.
3- Verify that git can be run from PowerShell. If the command is not found, you will need to add a git alias or add %ProgramFiles%\Git\cmd to your PATH environment variable.
4- Clone the posh-git repository to your local machine.
5- From the posh-git repository directory, run .\install.ps1.
Enjoy ;)

Related

The android sdk location cannot be at the filesystem root

I have installed Android Studio in the F:\ drive. My Flutter project is in the E:\ drive.
The Flutter plugin is installed in the Android Studio. But when I open my project in Android Studio and I go to the SDK Manager, it shows the following error:
The android sdk location cannot be at the filesystem root
Every package is disabled and the checkboxes are disabled, so I cannot click them to install Android SDK. The "Edit" link next to the error is not working either.
I came with the same problem because of forgetting "sudo"
Using the new android studio (bumble bee version) .
Restart the app and make sure you have an internet access
That will be enough to create the SDK and it’s directories
Just press Edit ( It is clickable) then download and install the required components.
Download the SDK first, and restore the default settings.
You can find the "Restore default settings" feature here.
What you can do is that you click on edit to surely you will get some version of Android that installs it by default and you click on next it will open another configuration verification window and you click on the next one for last it will tell you or It will update the version of android that was downloaded by default and you click again to finish and you can just select other versions of Android. That worked for me. Linux Ubuntu 20.04.4 LTS
Step 1:
Step 2:
Step 3:
Step 4:
Ready!!
For me it was the system language on Windows, I have changed it to English and it worked.
TL; DR
Make sure:
Your user has write permission into Android SDK directory.
ANDROID_HOME is correctly defined with the correct SDK location.
Description
IMHO it is a really bad practice install SDK into user home directory because:
Packages added will be restricted to a single user.
System administrators won't be able to mirror OS images, thus each engineer will have to install SDK manually.
The old school way is according to Linux directory hierarchy as described at The Linux Documentation Project, which consists on:
Ensure your user has adm privileges
Export SDK environment variables
Obey the filesystem hierarchy, installing the IDE and SDK into /opt
The steps above work perfectly on Ubuntu 22.04 and shall work on other distros with minor adjustments.
1. Ensure your user has adm privileges
grep adm /etc/group | grep ${USER}
adm:x:4:syslog,ventura
lpadmin:x:122:ventura
2. Configure environment variables
/etc/profile.d/
├── ...
├── android.sh
├── ...
├── java.sh
└── ...
where android.sh contains
#!/usr/bin/env bash
export ANDROID_HOME=/opt/google/android/
export FLUTTER_HOME=${ANDROID_HOME}/flutter
TOOLS=${ANDROID_HOME}/platform-tools
TOOLS=${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/tools:${TOOLS}
export PATH=${FLUTTER_HOME}/bin:${TOOLS}:${PATH}
and java.sh your JRE directory
#!/usr/bin/env bash
export JAVA_HOME=/usr/lib/jvm/java-18-openjdk-amd64
3. Install Android Studio and Android SDK
Download latest Android Studio and unpack it into /opt/jetbrains/:
VERSION=2021.2.1.16
sudo mkdir -p /opt/google/android
sudo mkdir -p /opt/jetbrains/studio
# Unpack Android Studio into a versioned folder
tar -xvzf android-studio-${VERSION}-linux.tar.gz
sudo mv android-studio /opt/jetbrains/studio/${VERSION}
# Grant write permission to administrators
sudo chown root:adm -R /opt/jetbrains/
sudo chmod g+w -R /opt/jetbrains/
sudo chown root:adm -R /opt/google/android
sudo chmod g+w -R /opt/google/android
Finally launch Android Studio and choose the SDK location:
This approach is extremely powerful because it allows system administrators duplicate development workstations using rsync -avz without relying onto any username or custom privileges.
I searched for many hours for an answer to this
I reinstalled:
I opened a new folder called Android in C:
Into it I reinstalled the android studio
You have created a new SDK folder within it
Then in the blank path, I entered C: \ Android \ sdk
And that's how it all worked.
Try it!
You can clear invalidate caches and restart android studio like follow picture:
Then start download sdk files :)
Make sure that your internet is working and try to close VPN connections if you have any. Then restart Android Studio and hope for the best.
To solve this issue, I had to close Android studio entirely. When I started the application again, it detected that it had a missing SDK problem and then went ahead with the installation process for it.
Your country should not be among the sanctioned countries (using VPN).
Android Studio by Run as Administrator open.
Download : Android SDK and Android SDK Platform.
Fix error: the android sdk location cannot be at the filesystem root.
For test The VPN is working properly.
Open website : https://developer.android.com/
this is the best solution to this error which is just under any drive you have on your laptop which C:// open a folder called "Android" and under the android folder open a folder called "sdk" and change the sdk file path to this recently created folder. That's All.

Unity build error. [Failed to install the following Android SDK packages as some licences have not been accepted. ]

After I carried out some commands below on terminal to test my unity app with android emulators. My Unity project started failing build over and over again due to the same error in the pics below. If there is anybody who are familiar with this issue, would you give me advice to address it?
The command I carried out on terminal
1, export PATH=$PATH:/Users/userName/Library/Android/sdk/platform-tools
2, echo PATH=$PATH: /Users/userName/Library/Android/sdk
3, cd /Users/userName/Desktop/AppName.apk
4, adb install AppName.apk
The details of the error
enter image description here
enter image description here
For people who may face the same errors in the future,
The problem was there is no licences file in /Users/username/Desktop/2019.2.9f1/PlaybackEngines/AndroidPlayer/SDK.
So I copied the file from /Users/username/Library/Android/sdk and paste it to the unity directory above.
The errors was successfully addressed.
I wish nobody wasted their time anymore because of this error.
Open command prompt as admin and run
{path_to_sdk_folder}/tools/bin/sdkmanager.bat --licenses
and accept all.
If anyone else happens to run into this problem, and you are using Unity Hub, run the following command from Terminal.
$ find /Applications/Unity/Hub/Editor -name "sdkmanager" -exec {} --licenses \;
This will find all of the installed SDKs and check that all licenses are accepted. If they aren't, you will be prompted to accept.
You can run the command again to double-check everything is 100%.
Keep bumping into this now Unity manages the platforms, Android Studio then grumbles about it if you point Android Studio at the platforms location Unity is using.
On Windows the quick and dirty fix is to run Android Studio as administrator, it then does what it needs and you can then go back to running Android Studio normally.
Not sure what the effects are long term, but it appears to work for me. Especially as I am not using the platform that Android Studio is grumbling about.
However, clearly, this isn't a great solution as the SDK manager in Android Studio doesn't see the platforms Unity claims to have installed.
On a Windows machine, you'll need to find your sdkmanager.bat for your current version of Unity. For you this location could be something like
C:\Program Files\Unity\<version>\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin\sdkmanager.bat
or
C:\Program Files\Unity\Hub\Editor\<version>\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin\sdkmanager.bat
Once you find this, you can execute it with the --licenses flag in Powershell or your shell of choice, like below. Make sure that you run your shell as an administrator.
.\sdkmanager.bat --licenses
You'll then be prompted to review any licenses that have yet to be accepted. Answering y to these will resolve the issue.
Kotaro is right.
For people who may face the same errors in the future,
The problem was there is no licences file in /Users/username/Desktop/2019.2.9f1/PlaybackEngines/AndroidPlayer/SDK.
So I copied the file from /Users/username/Library/Android/sdk and paste it to the unity directory above.
The errors was successfully addressed.
I wish nobody wasted their time anymore because of this error.
Cant comment so :
This is correct but make sure you open CMD with admin privileges as it wont save the licenses!
Go to src -> flutter -> flutter -> flutter_console
and type flutter doctor --android-licenses. Click y.

How can I correctly set up UiAutomatorViewer to inspect elements for testing Android apps with Appium?

When running uiautomatorviewer, I am getting the following NullPointerException error:
I have installed and set up Appium following the setup process and set up environment variables for ANDROID_HOME and the Android SDK. The uiautomatorviewer command is using a Path user variable that points to the directory Sdk/tools/bin, where the uiautomatorviewer.bat file is located. From everything I've read online, running this executable should open up the UiAutomatorViewer application, so I can inspect elements on my Android app. Why isn't this working?
The correct fix for this issue:
Java SDKs 9 and 10 do not work with Appium and the Android SDK. You have to uninstall the Java SDK for the more recent version and install the Java 8 SDK instead.
For Linux
Follow this process:
brew cask uninstall java # uninstall java9
brew tap caskroom/versions
brew cask install java8 # install java8
touch ~/.android/repositories.cfg # without this file, error will occur on next step
brew cask install android-sdk
For Windows
Open Add or Remove Programs menu and uninstall Java 9/10.
Install Java 8 using the installer.
Can you just reconnect the device and restart it and the uiautomator? But make sure the test script is not running in the background. Or you can kill the adb server and restart it again.
You can go and check if you forgot any steps in UIAutomatorViewer Tutorial: Inspector for Android Testing.
I was using uiautomatorviewer with corretto-11.0.13 (after some edits in a .bat file) until I upgraded Android Studio to 2021.2.1 (Chipmunk) (to solve another issue in the Android build) and the problem didn't disappear. Moreover, more problems appeared. uiautomatorviewer didn't work again.
I rolled back to Android Studio 4.1.1, restored a change done in the find_java.bat file, and it worked again.
You must add the following Android/sdk/tools/bin/ in the system environment variable.
If you are using window os, you can do it like following:
Right-click on ‘This PC’ and select Properties.
Click 'Advanced system settings' and select ‘Environmental Variables’ option
Under the 'System variables", select 'Path' and click 'Edit'
Click 'New" and add the path of Android/sdk/tools/bin/ in the like
C:\Users\\AppData\Local\Android\Sdk\tools\bin
then you will be able to run uiautomatorviewer command in the command prompt.
The alternative way is to open command prompt in Android/sdk/tools/bin/ folder and then run uiautomatorviewer command.

Launch Android SDK manager - Tools directory doesn't exist? Mac

I'm on mac, I think I've done everything right so far. following these instructions:
http://developer.android.com/sdk/installing/adding-packages.html
it says to navigate to tools/ directory in terminal. Here are my steps.
Open terminal
cd Applications
result is: No such file or directory
path to my tools directory is as follows
Applications->adt-bundle-mac-x86_64-20130219 ->SDK -> tools
I tried putting my folder onto my desktop, both the tools folder, and my adt-bundle because I could change directory to my desktop, and when I enter ls to the terminal I see my tools folder, and my adt-bundle is there,
but the problem is when I try to enter
cd tools
or
cd adt-bundle(etc...)
it says that it is not a directory.
what do I do?
Go to this directory:
cd /adt-bundle-mac-x86_64-20131030/sdk/tools
and run:
./android
I recently encountered this issue, and figured I'd post on this for clarification or for anyone still encountering it.
It seems you have to be at the root of the /adt-bundle-mac-VERSION/sdkdirectory in order to execute the "android" command.
I normally cd into the directory until I reach the location of the command, but in this case I encountered the same issue as the original poster.
You must use the tab key to the android command...
ie...
locate your installation /adt-bundle-mac-x86_64-20131030/sdk hit TAB key /tools hit TAB key /android
instead of cd adt-bundle-mac-x86_64-20131030/ cd/sdk cd/tools android
If done properly the SDK manager should launch for you.
Hope this helps anybody out there.
You can launch the SDK Manager by using the GUI:
Launch Android Studio
Create a new blank project
In the toolbar, look for the icon with tooltip "SDK Manager"
A lot of answers have been given here that you should go to /{path-to-your-android-sdk}/tools
and run ./android.
For me, this did not work. When I opened the android file located at my /{path-to-your-android-sdk}/tools directory with a text editor, it contained the following:
#!/bin/bash
echo The "android" command is no longer available.
echo For manual SDK and AVD management, please use Android Studio.
echo For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
exit 1
So the right approach now, is as stated by #Shijil in his comment.
In the directory for your android sdk, you should use:
For SDK Manager:
cd tools
cd bin
./sdkmanager
For AVD Manager:
cd tools
cd bin
./avdmanager
NB For the last command in each of the options above, you will have to supply additional args depending on the operation you want to perform. An example arg that works for both is --list. Running the commands without any args will only display the possible args you could have passed.
Personally, I think using the GUI in android studio is easier. Especially for linux beginners.
Use cd /users/user/...your path.../android-sdk/tools
and then :
./android
Here is your "tools" directory for Android Studio in OS X El Captain(Yosemite also has the same path hopefully):
Users/user-name/Library/Android/sdk/tools
In the terminal, just type: Library/Android/sdk/tools
and hit enter. And you are in the tools folder.
Please note that user-name refers to the mac user
Better open terminal and type which android.
It will tell you the path where you have the package installed.
Then yeah, you just have to execute that path on the terminal.
Your android package might have been installed with Homebrew or others, so the path can be different.
Edit: typo
For me the directory was cd /Users/your_user_name/Library/Android/sdk/tools/
and after that the command was ./android list targets
I hope this can help

How do i run the Android command line tools?

I'm still pretty new to Android and programming in general, and I can't seem to get the command line tools packaged with the Android SDK to work. I'm running Mac OSX and each time I try to run layoutopt, for example, the terminal returns, *-bash: cmd: command not found
*
Also, is it okay to have my SDK located in the Developer directory and my android project in some unrelated directory when using these tools?
If you want you can put the path in your ~/.bash_profile so you can call it from anywhere:
export ANDROID_HOME=/Users/<username>/path/to/sdk/tools
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
You may want to include also the platform-tools into your ~./bash_profile
### Android dev tools
export ANDROID_HOME="/Users/myusername/DEV/tools/adt-bundle-mac-x86_64/sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
You will need to start a new terminal session or run
source ~/.bash_profile
to loads the values immediately without having to open a new terminal session.
The current (2016-08-17) answer to this question is:
~/Library/Android/sdk
So my bash_profile contains:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
I figured it out. I needed to go to the /tools directory in the SDK folder and type in:
./layoutopt <directorypath>
Problem is your command line tool is not seeing required programs from /path/to/sdk/tools.
One solution as user NKijak mentioned is to add those tools to your Home path and the other is to run command line from location where your sdk tools are stored. Here is a tutorial how to do just that http://hathaway.cc/2008/06/how-to-edit-your-path-environment-variables-on-mac-os-x/
Other way is, when opening command line just change your current dir to /path/to/sdk/tools and then run the tools. In windows you can just shift+right click in file explorer and pick open command windows here I am not sure is there equivalent on MacOS but there are some extensions you can install to add this option. Also total commander in windows has command line where you can start command line from current location there are similar programs on mac like Midnight Commander that have same option.
Here is a good description:
To connect to the console of any running emulator instance at any time, use this command:
telnet localhost <console-port>

Categories

Resources