Sunday, May 2, 2021

Android Studio (aka intellij) tips and tricks

0_Unsorted_

Appearance (theme) of the code editor and/or menus broke down:

Hardcode from stackoverflow, worked for me:

That is for the known bug of the "Arctic Fox" Android Studio release.
From here.
Rename the {path-of-android-studio}/lib/gson-2.7.jar file to gson-2.7.jar.disabled.
Restart Studio.

Import backup settings of Android Studio 

..that we saved beforehand to some safe place such as Google Drive

Restore default settings

Android Studio menu ->

File ->

Manage IDE Settings ->

Restore default

Uninstall and install the studio again 

(costly solution). 

Find out where and how studio was installed:

- Go to the parent directory of Linux in terminal: cd ~

- Find the android studio directory: find . -type d -name android-studio

If it is in snap folder, commands for uninstalling and installing are simple:

- sudo snap remove android-studio

- sudo snap install android-studio --classic

Use Android command line SDK and Vim instead of Android Studio for developing

Android Studio is based on Intellij which is kind of crap.

How to see location of the Android Studio settings

This is often needed when after having some problem with studio, we reinstall it, however the application takes the settings from the previous place (which is a different folder).
Solution: (how to find the default Android Studio settings directory): in Android Studio, press File -> Manage IDE settings -> Export Settings. It will show the path to the current settings directory.

Problems with SDK

E. g. SDK location not found, not enough space to install SDK etc.
Solution: In Android Studio, press File -> Settings -> Appearance and behavior -> System settings -> Android SDK. Then in the "Android SDK Location" line click "Edit". It will then let to install SDK missing packages.

Android Studio won't start even after reinstalling

Remove all the settings remained from previous installations in different folders other than installation directory. See also this from official Google.
Failed to install the following Android SDK packages as some licences have not been accepted
Credits to this solution:
In Android Studio click the consequence:
Tools
SDK Manager
"SDK Tools" horizontal tab
Android SDK Build-Tools
"Show Package Details" checkbox in the right bottom corner
Choose version, which is note in the error text (when I tried to build)
Mark it with galochka on the right\
Click "Apply"

Please select Android SDK

Solution:
        Make sure you have no uncommitted changes
        Sync your local repository with remote github
Delete folder with the local repository
Clone the repository from github to local again
Open the cloned repository in the Android Studio
Build and run it again.

Selected directory is not valid home for Android SDK

Solution:
Delete the current directory with Android SDK via terminal or file manager.
Select the new directory via Android Studio -> File -> Settings -> Appearance and Behavior -> System settings -> Android SDK -> Android SDK Location.
"gradlew command not found
Run the following commands in the terminal:
chmod +x ./gradlew
chmod +x ./gradlew
Then try ./gradlew again
Credits to this stackoverflow question

Can't see SDK Manager under the "Tools" menu of the Android Studio

Solution: Search "SDK" in the File->Settings.

Turn on/off preview of strings resources values

In Android Studio go to File -> Settings -> Editor -> General -> Code Folding -> uncheck "Android String References". After reopening the file, string resources should not be previewed. Credits to this stackoverflow question.

How to disable double-shift keyboard shortcut

Press Ctrl+Shift+A and search for "Disable double modifier key shortcuts". Check it then.

Useful keyboard shortcuts

Select device to run the app at: Alt+Shift+F11

Search by file name: Ctrl+Shift+N

Search any action (command, menu etc): Ctrl+Shift+A

Search keyword inside of files: Ctrl+Shift+F. Make sure that file mask (in the right top of the search window) is turned off, otherwise it will search not everywhere.

Editor layout: If the view is split into 2 parts, I can press the "B" key ("Select Design Surface")

Switch between file tabs to the next left/right tab: Alt+Shift+Left/Right

Switch between Code and Design view for xml files: Ctrl + Alt + F7.

Close the bottom part of the screen with Logcat, Build, Run etc: Shift + Esc

In the code editor, extra redundant indents are placed automatically

Go to File -> Settings -> Editor -> General -> Smart keys -> Enter -> Smart indent

Or merely type "indent" in the Settings search box to find this section faster.

Turn off this checkbox.

No comments:

Post a Comment