Android TutorialAdding a FuseView to an Android ProjectAndroid 9-Patch ImagesAndroid Accessing SQLite databases using the ContentValues classAndroid Accounts and AccountManagerAndroid ACRAAndroid ActivityAndroid Activity RecognitionAndroid adb (Android Debug Bridge)Android adb shellAndroid AdMobAndroid AIDLAndroid AlarmManagerAndroid Android-x86 in VirtualBoxAndroid Animated AlertDialog BoxAndroid AnimatorsAndroid Annotation ProcessorAndroid Architecture ComponentsAndroid AsyncTaskAndroid AudioManagerAndroid AudioTrackAndroid AuthenticatorAndroid AutoCompleteTextViewAndroid Autosizing TextViewsAndroid Barcode and QR code readingAndroid Bitmap CacheAndroid Bluetooth and Bluetooth LE APIAndroid Bluetooth Low EnergyAndroid Bottom SheetsAndroid BottomNavigationViewAndroid BroadcastReceiverAndroid Building Backwards Compatible AppsAndroid ButterKnifeAndroid ButtonAndroid Callback URLAndroid Camera 2 APIAndroid Camera and GalleryAndroid Canvas drawing using SurfaceViewAndroid Capturing ScreenshotsAndroid CardViewAndroid Check Data ConnectionAndroid Check Internet ConnectivityAndroid CleverTapAndroid ColorsAndroid ConstraintLayoutAndroid ConstraintSetAndroid ContentProviderAndroid ContextAndroid CoordinatorLayout and BehaviorsAndroid Count Down TimerAndroid Crash Reporting ToolsAndroid Create Singleton Class for Toast MessageAndroid Creating Custom ViewsAndroid Creating Overlay (always-on-top) WindowsAndroid Creating Splash screenAndroid Custom FontsAndroid Dagger 2Android Data Binding LibraryAndroid Data Encryption/DecryptionAndroid Data Synchronization with Sync AdapterAndroid Date and Time PickersAndroid DayNight Theme (AppCompat v23.2 / API 14+)Android Define step value (increment) for custom RangeSeekBarAndroid Design PatternsAndroid Device Display MetricsAndroid DialogAndroid Displaying Google AdsAndroid Doze ModeAndroid DrawablesAndroid EditTextAndroid Email ValidationAndroid EmulatorAndroid Enhancing Alert DialogsAndroid ExceptionsAndroid ExoPlayerAndroid FastjsonAndroid fastlaneAndroid FileProviderAndroid FirebaseAndroid Firebase App IndexingAndroid Firebase Cloud MessagingAndroid Firebase Crash ReportingAndroid Firebase Realtime DataBaseAndroid FloatingActionButtonAndroid Formatting phone numbers with pattern.Android Formatting StringsAndroid FragmentsAndroid FrescoAndroid game developmentAndroid Gesture Detection

Android Studio

From WikiOD

Setup Android Studio[edit | edit source]

System Requirements

  • Microsoft® Windows® 8/7/Vista/2003 (32 or 64-bit).
  • Mac® OS X® 10.8.5 or higher, up to 10.9 (Mavericks)
  • GNOME or KDE desktop



  1. Download and install JDK (Java Development Kit) version 8
  2. Download Android Studio
  3. Launch Android Studio.exe then mention JDK path and download the latest SDK


  1. Download and install JDK (Java Development Kit) version 8
  2. Download Android Studio
  3. Extract the zip file
  4. Open terminal, cd to the extracted folder, cd to bin (example cd android-studio/bin)
  5. Run ./

View And Add Shortcuts in Android Studio[edit | edit source]

By going to Settings >> Keymap A window will popup showing All the Editor Actions with the their name and shortcuts. Some of the Editor Actions do not have shortcuts. So right click on that and add a new shortcut to that.

Check the image below


Custom colors of logcat message based on message importance[edit | edit source]

Go to File -> Settings -> Editor -> Colors & Fonts -> Android Logcat

Change the colors as you need:


Choose the appropriate color:


Enable/Disable blank line copy[edit | edit source]

ctrl + alt + shift + / (cmd + alt + shift + / on MacOS) should show you the following dialog:


Clicking on Registry you will get


The key you want to enable/disable is


Tested on Linux Ubuntu and MacOS.

Android Studio useful shortcuts[edit | edit source]

The following are some of the more common/useful shortcuts.

These are based on the default IntelliJ shortcut map. You can switch to other common IDE shortcut maps via File -> Settings -> Keymap -> <Choose Eclipse/Visual Studio/etc from Keymaps dropdown>

Action Shortcut
Format code CTRL + ALT + L
Add unimplemented methods CTRL + I
Show logcat ALT + 6
Build CTRL + F9
Build and Run CTRL + F10
Find CTRL + F
Find in project CTRL+SHIFT + F
Find and replace CTRL + R
Find and replace in project CTRL + SHIFT + R
Override methods CTRL + O
Show project ALT + 1
Hide project - logcat SHIFT + ESC
Collapse all CTRL + SHIFT + NumPad +
View Debug Points CTRL + SHIFT + F8
Expand all CTRL + SHIFT + NumPad -
Open Settings ALT + s
Select Target (open current file in Project view) ALT + F1 → ENTER
Search Everywhere SHIFT → SHIFT (Double shift)
Surround With CTRL → ALT + T
Create method form selected code ALT + CTRL


Action Shortcut
Refactor This (menu/picker for all applicable refactor actions of the current element) Mac CTRL + T - Win/Linux CTRL + ALT + T
Rename SHIFT + F6
Extract Method Mac CMD + ALT + M - Win/Linux CTRL + ALT + M
Extract Parameter Mac CMD + ALT + P - Win/Linux CTRL + ALT + P
Extract Variable Mac CMD + ALT + V - Win/Linux CTRL + ALT + V

Android Studio Improve performance tip[edit | edit source]

Enable Offline Work:

  1. Click File -> Settings. Search for "gradle" and click in Offline work box.
  2. Go to Compiler (in same settings dialog just below Gradle) and add --offline to Command-line Options text box.

Improve Gradle Performance

Add following two line of code in your file.


Increasing the value of -Xmx and -Xms in studio.vmoptions file



%USERPROFILE%.{FOLDER_NAME}\studio.exe.vmoptions and/or %USERPROFILE%.{FOLDER_NAME}\studio64.exe.vmoptions




~/.{FOLDER_NAME}/studio.vmoptions and/or ~/.{FOLDER_NAME}/studio64.vmoptions

Filter logs from UI[edit | edit source]

Android logs can be filtered directly from the UI. Using this code

public class MainActivity extends AppCompatActivity {
    private final static String TAG1 = MainActivity.class.getSimpleName();
    private final static String TAG2 = MainActivity.class.getCanonicalName();

    protected void onCreate(Bundle savedInstanceState) {
        Log.e(TAG1,"Log from onCreate method with TAG1");
        Log.i(TAG2,"Log from onCreate method with TAG2");

If I use the regex TAG1|TAG2 and the level verbose I get

01*14 10:34:46.961 12880-12880/ E/MainActivity: Log from onCreate method with TAG1
01*14 10:34:46.961 12880-12880/ I/ Log from onCreate method with TAG2


The level can be set to get logs with given level and above. For example the verbose level will catch verbose, debug, info, warn, error and assert logs.

Using the same example, if I set the level to error, I only get

01*14 10:34:46.961 12880-12880/ E/MainActivity: Log from onCreate method with TAG1


Create filters configuration[edit | edit source]

Custom filters can be set and save from the UI. In the AndroidMonitor tab, click on the right dropdown (must contains Show only selected application or No filters) and select Edit filter configuration.

Enter the filter you want


And use it (you can selected it from the same dropdown)


Important If you add an input in the filter bar, android studio will consider both your filter and your input.

With both input and filter there is no output Custom filter with input

Without filter, there is some outputs Filter input only

Gradle build project takes forever[edit | edit source]

Android Studio -> Preferences -> Gradle -> Tick Offline work and then restart your Android studio.

Reference screenshot:


Create assets folder[edit | edit source]

  • Right click in MAIN folder > New > Folder > Assets Folder.
  • Assets folder will be under MAIN folder with the same symbol as RES folder.
  • In this example I put a font file. Android_Studio