How to Install Android Studio on Ubuntu 24.04, 22.04 or 20.04

This guide will unveil the steps for installing Android Studio on Ubuntu 24.04, 22.04, or 20.04 LTS Linux releases. It delves into the utilization of a command-line terminal, leveraging a reputable LaunchPAD PPA maintained by Maarten Fonville.

Android Studio stands as the official Integrated Development Environment (IDE) for Android application development, directly backed by Google. It’s designed to provide developers with a seamless and efficient workflow for creating Android apps, offering a rich set of tools and features that cater to the needs of both beginners and seasoned developers. Here are some of its key highlights:

  • Integrated Emulator: A high-performance, feature-rich emulator for testing Android applications across a wide range of devices.
  • Code Editor: Offers advanced code completion, refactoring, and linting capabilities, making coding more efficient and less error-prone.
  • Build Tools: Incorporates Gradle-based build support for flexible and scalable project management.
  • Layout Editor: Enables the visual design of application UIs, simplifying the process of designing complex layouts.
  • APK Analyzer: Helps reduce APK file sizes by providing insights into the contents and sizes of the components.
  • Profiling Tools: Offers powerful tools to identify performance bottlenecks by monitoring memory usage, CPU activity, and more.
  • Version Control: Integrated support for Git, SVN, and other version control systems to manage project changes effectively.
  • Plugin Ecosystem: A broad range of plugins and extensions available to extend functionality and tailor the development environment to specific needs.

With these features, Android Studio aims to streamline the development process, making it more accessible and productive for developers. Let’s transition seamlessly into the technical steps to get Android Studio up and running on your Ubuntu system.

Install Android Studio on Ubuntu via APT

Import Android Studio PPA on Ubuntu

To install Android Studio, make sure that your system packages are up-to-date. Open the terminal and execute the command below to update your package list and install any available updates:

sudo apt update && sudo apt upgrade

After updating your system packages, import the Android Studio PPA by running the following command:

sudo add-apt-repository ppa:maarten-fonville/android-studio -y

This command adds the PPA appropriate only for short-term releases of supported Ubuntu versions.

Install Android Studio on Ubuntu via APT Command

After importing the Android Studio PPA, run the “apt update” command to reflect the newly imported PPA. Use the following command to do so:

sudo apt update

Complete the update, then proceed to install Android Studio using the command below:

sudo apt install android-studio

This will install the latest version of Android Studio on your system.

Also, you will need to have java installed, the best method is to install the default preferred version for your Ubuntu system using the following command:

sudo apt install default-jdk

Note: If you have Java installed and ready, the above command can be skipped.

Launch Android Studio on Ubuntu

CLI Command to Launch Android Studio UI

To launch Android Studio immediately, run the following command from your command-line:

android-studio

GUI Path to Launch Android Studio

To launch Android Studio on your Ubuntu system, follow the steps below:

  1. Click on the “Activities” button in the top left corner of your screen.
  2. Type “Android Studio” in the search bar or scroll down to find it under the “Show Applications” section.
  3. Click on the Android Studio icon to launch the application.
Demonstrating launching Android Studio from the application icon on Ubuntu 24.04, 22.04, or 20.04.
How to launch Android Studio from the Ubuntu application menu.

First-Time Setup of Android Studio

Upon launching Android Studio for the first time, you’ll encounter the Setup Wizard. The Wizard facilitates the initial setup process, including:

  • Acceptance of EULA
  • Importing settings
  • Configuring necessary options

To use the Android SDK and its components, you must accept both the Android-sdk-license and Android-sdk-preview licenses. Although the interface initially appears overwhelming with its numerous options and settings, practice will make navigation and use easier.

Accepting the license agreement for Android Studio on Ubuntu 24.04, 22.04, or 20.04.
Agreement acceptance screen for Android Studio on Ubuntu.

First-Time Tips with Android Studio on Ubuntu

Now that Android Studio is set up on your Ubuntu system, diving into its vast array of features and settings can significantly enhance your development workflow.

Optimizing Your Workspace

  • Increase Memory Allocation: To ensure Android Studio runs smoothly, adjust the memory settings in studio.vmoptions. Increasing the IDE’s available memory can reduce lag and improve performance. Open this file from Help > Edit Custom VM Options and adjust the -Xmx parameter to a higher value, like -Xmx4g, depending on your system’s available memory.
  • Enable Save Actions: Automate code optimization by enabling Editor > General > Save Actions. Configure it to organize imports and reformat code on save, keeping your codebase clean without extra effort.
  • Utilize the Distraction-Free Mode: Focus on coding by activating the Distraction-Free Mode from View > Appearance. This hides all other panels and toolbars, offering you a clutter-free coding space.
  • Customize the Theme and Font: Tailor the IDE’s appearance to your liking for better readability and comfort. Access File > Settings > Appearance & Behavior > Appearance to select a theme and Editor > Font to choose a font that suits you best.

Efficient Code Navigation

  • Master the Navigation Bar: Quickly move between files and symbols by using the navigation bar. Press Alt + Home to access it, and start typing the name of the file or symbol you’re interested in.
  • Use Bookmarks: Mark important sections of your code with bookmarks for easy access. Press Ctrl + F11 to bookmark a line, and use Shift + F11 to view all bookmarks.
  • Speedy File Switching: Switch between open files effortlessly with Ctrl + Tab, allowing you to navigate through your recent files without taking your hands off the keyboard.
  • Navigate to Declaration: Instantly go to the declaration of a class, method, or variable by placing the cursor on it and pressing Ctrl + B.

Mastering Keyboard Shortcuts

  • Refactoring: Use Shift + F6 to rename symbols across your codebase efficiently.
  • Quick Fix: Press Alt + Enter to access the suggested fix for warnings and errors in your code.
  • Search Everywhere: Quickly find anything within Android Studio by pressing Shift + Shift. This includes commands, files, symbols, and settings.
  • Live Templates: Speed up coding by using live templates. Press Ctrl + J to insert pre-defined code snippets.

Version Control Integration

  • Commit Changes: Use Ctrl + K to commit changes directly from the IDE.
  • Update Project: Synchronize your project with the repository using Ctrl + T.
  • View Recent Changes: Press Alt + Shift + C to view recent changes in your project.
  • Branch Management: Access the VCS operations popup with Ctrl + V to quickly switch branches or merge changes.

Debugging and Profiling

  • Debug Your App: Start debugging your app by pressing Shift + F9. This allows you to step through your code and inspect variables.
  • CPU Profiler: Access the CPU Profiler via View > Tool Windows > Profiler to analyze CPU usage and identify performance bottlenecks.
  • Memory Profiler: Similarly, use the Memory Profiler to monitor memory usage and detect memory leaks.
  • APK Analyzer: Optimize your app’s size by analyzing the APK file. Access this feature through Build > Analyze APK.

Plugins and Customization

  • Install Plugins: Enhance your IDE’s functionality by installing plugins from the marketplace. Access this via File > Settings > Plugins.
  • Code Style Settings: Configure your project’s code style in File > Settings > Editor > Code Style to ensure consistency across your team.
  • Keymap Customization: Tailor keyboard shortcuts to your preference for an even more efficient workflow. Adjust these in File > Settings > Keymap.

Integrating these tips into your development process, you’ll harness the full potential of Android Studio on Ubuntu, leading to a more productive and enjoyable coding experience.

Android Studio ready for use on Ubuntu 24.04, 22.04, or 20.04 system.
Android Studio setup completed on Ubuntu.
Android Studio project overview on Ubuntu 24.04, 22.04, or 20.04.
Android Studio project in progress on Ubuntu.

Additional Android Studio Commands with Ubuntu

Remove Android Studio

If you no longer need Android Studio on your Ubuntu system and want to remove it, follow these steps:

Remove Android Studio and its dependencies:

To remove Android Studio and its dependencies, use the following command in the terminal:

sudo apt remove android-studio

Remove the imported PPA:

If you have no plans of reinstalling Android Studio, you can remove the imported PPA to keep your system tidy using the following command:

sudo add-apt-repository --remove ppa:maarten-fonville/android-studio -y

This command will delete your system’s Android Studio PPA file, preventing its use for future software installations.

Conclusion

Throughout this guide, we’ve walked you through the steps to get Android Studio up and running on Ubuntu 24.04, 22.04, or 20.04 LTS. From installation to optimizing your workspace and mastering key shortcuts, we aimed to equip you with the essentials to kickstart your Android development journey. As you dive into your projects, remember the importance of customizing the environment to suit your workflow—it’s a game-changer. Also, don’t shy away from exploring the plethora of plugins available to boost your productivity. Keep experimenting, stay curious, and happy coding on your Ubuntu system!

Leave a Comment