Search by tag: android studio

5 articles

How to run two Android Studio instances on macOS

If you're an Android developer who juggles both professional and personal projects, you've probably faced this dilemma: you want to experiment with new plugins, test beta features, or try out different configurations on your personal projects—but you can't risk breaking your stable, production-ready setup.

The solution? Run two independent copies of Android Studio on the same Mac. This guide walks you through creating a completely isolated custom instance alongside your regular one, with separate configurations, caches, and settings.

Step-by-step setup

1️⃣ Copy the Android Studio bundle, in order to update its configuration.

First, create a duplicate of your existing Android Studio application. Here I had already manually installed another copy, but you could directly duplicate your original regular installation, that should be located in /Applications/Android\ Studio.app

Adjust the paths to match your actual installation location.

ORIG="$HOME/Applications/Android Studio Perso/Android Studio Perso.app"
COPY="$HOME/Applications/Android Studio Perso/Android Studio Perso-copy.app"

cp -R "$ORIG" "$COPY"

2️⃣ Remove macOS quarantine attributes

macOS marks downloaded or copied applications with a quarantine flag that can prevent them from launching properly:

xattr -dr com.apple.quarantine "$COPY"

3️⃣ Clear immutable flags

Some installations may have immutable flags set:

chflags -R nouchg "$COPY"

4️⃣ Configure separate directories

Find and edit the idea.properties file inside the copied application:

FILE=$(find "$COPY" -type f -name idea.properties)
vi "$FILE"

Uncomment these four lines, and modify the two first ones to point to your personal configuration directory:

idea.config.path=${user.home}/.AndroidStudioPerso/config
idea.system.path=${user.home}/.AndroidStudioPerso/system
idea.plugins.path=${idea.config.path}/plugins
idea.log.path=${idea.system.path}/log

Save and exit. This ensures your custom instance stores all settings, caches, and logs separately from your regular one.

5️⃣ Clean recent projects list (optional)

Remove the cached recent projects file to start fresh:

rm -f "$HOME/.AndroidStudioPerso/config/options/recentProjects.xml"

6️⃣ Launch the new instance

Open your copied application:

open "$COPY"

On first launch, macOS may display a security popup. Click Cancel, then go to System Settings > Privacy & Security and authorize the application to run.

The security popup preventing the copy to be opened

Authorize the copy of Android Studio in Security settings

7️⃣ (Optional) Overwrite your previous copy

If you duplicated a previous custom installation:

rm -rf "$ORIG"
mv "$COPY" "$ORIG"

The two versions appear in search

Android Studio shortcuts on macOS

This post will serve as a memo for the most useful shortcuts in Android Studio, running on macOS.

I use the IdeaVim plugin, which may cause conflicts with the default shortcuts. Thus, some of my shortcuts could be different from yours. Android Studio allows the remapping of all its features (or almost ?) in Settings => Keymap

Keymap settings window in Android Studio

Navigation / Error handling

  • F2 – Jump to the next error or warning in the file.

Refactoring

  • Shift + F6 – Rename the selected symbol (class, method, variable, etc.).
  • ⌘ T – Open the Refactor submenu (same as right‑click → Refactor).
  • ⌥ ⌘ P – Introduce a parameter to a function/method declaration.
  • ⌥ ⌘ M – Extract the selected code into a new function.
  • ⌥ ⌘ V – Extract the selected expression into a new variable.
  • ⌥ ⌘ F – Extract the selected expression into a new property (field).
  • ⌥ ⌘ N – Inline a property (replace its usages with the underlying expression).

Editing / Moving code

  • ⌥ ↑ / ⌥ ↓ – Extend the current selection upward or downward (expand selection).
  • ⌥ ⇧ ↑ / ⌥ ⇧ ↓ – Move the current line (or selected block) up or down.
  • ⌥ ⇧ Click – Add additional cursors at each click location (multiple‑cursor editing).

General movement

  • F6 – Move the selected element (e.g., a file or a UI component) to a new location.

Accessing your application database from Android Studio

Open the Terminal window (Alt + F12) or:

Open the Terminal window

Then list your devices with the adb command. This will display both running emulators and connected devices:

$ adb devices
List of devices attached
emulator-5554   device

Use the device name to open a connection:

$ adb -s emulator-5554 shell
generic_x86:/ $

To avoid a Permission denied error while trying to access your application files, use the run-as command:

generic_x86:/ $ run-as com.your.package.example sqlite3 databases/yourdatabase.db

Accessing your application files from Android Studio

While learning to play with SQLite databases in Android, I wanted to check the .db file generated by my code in the emulator. I was unable to find it directly with the built-in Files application because it doesn't let us see system folders.

The built-in Files app

Fortunately, Android Studio 3+ comes with the Device File Explorer, which allows us to browse system files and access the root data folder. To open it, go to View > Tool Windows > Device File Explorer. My application data was stored in /data/data/.

How to display the Device File Explorer


How to see the data stored in sqlite in android studio using genymotion as emulator

Alt+Insert shortcut not working with Fn key in Android Studio (and maybe elsewhere)

I have a TypeMatrix keyboard with quite a few keys requiring pressing the Fn key first.

A TypeMatrix keyboard

Insert is one of them. So if I want to use a shortcut like Alt+Insert, I usually just need to type Fn+Alt+Insert. But it does not work in Android Studio1 2, where I had to add a custom mapping. It appears that Fn+Alt is recognized as Alt Gr, which explains why the default shortcut was not triggered.

To add a custom mapping in Android Studio, go to File > Settings. In the popup window, click Keymap on the left and type generate in the search field. This will display the current mapping associated with the Generate... command. Double click on it to display the Edit Shortcuts menu and then choose Add Keyboard Shortcut to finally enter your custom shortcut.

Add a custom mapping in Android Studio

1 It happens I have noticed this while using Android Studio, but it probably happens in other software too.
2 I am currently using version 3.1.2.