CentOSRHEL Based

How To Install Android Studio on CentOS Stream 10

Install Android Studio on CentOS Stream 10

In this tutorial, we will show you how to install Android Studio on CentOS Stream 10.  Android Studio stands as the official Integrated Development Environment (IDE) for crafting Android applications. Leveraging the robust foundation of IntelliJ IDEA, it provides developers with an extensive toolkit to streamline app creation, testing, and debugging. Choosing the right operating system is crucial for a smooth development experience. CentOS Stream 10, with its stability and reliability, offers an excellent platform for running Android Studio.

Having Android Studio on CentOS Stream 10 provides a conducive environment for Android app development, allowing you to harness the power of both the IDE and the operating system. The purpose of this article is to furnish you with a comprehensive, step-by-step guide to installing Android Studio on CentOS Stream 10, ensuring a seamless setup and optimal performance. Let’s dive into the installation process.

Prerequisites

Before you begin the installation, ensure your system meets the necessary prerequisites. Proper preparation will help prevent potential issues during the installation process.

System Requirements

First, verify that your hardware meets the minimum requirements for running Android Studio smoothly. Insufficient hardware resources can lead to performance issues and a frustrating development experience.

  • RAM: A minimum of 8 GB RAM is recommended; 16 GB or more is ideal for smoother performance, especially when running emulators.
  • Disk Space: At least 8 GB of available disk space is necessary. Android Studio, the Android SDK, and associated emulators consume considerable space.
  • Processor: An x86_64 CPU architecture with 2nd generation Intel Core or later, or an AMD CPU with SSE4.1 and 64-bit support, is required.
  • Operating System: This guide is specifically for CentOS Stream 10, a stable and reliable Linux distribution.
  • 64-bit System: Ensure that you are running a 64-bit version of CentOS Stream 10, as Android Studio requires a 64-bit operating system.

Initial System Setup

Before installing Android Studio, update your system to ensure you have the latest packages and dependencies. An updated system reduces the likelihood of encountering compatibility issues during the installation.

  1. Open a terminal.
  2. Execute the following command to update your system:
    sudo dnf update
  3. Enter your password if prompted.
  4. Wait for the update process to complete.

It’s advisable to set up a user account with sudo privileges for performing administrative tasks. Using a non-root user with sudo privileges enhances system security.

  1. If you don’t already have a user with sudo privileges, create one using the following command:
    sudo adduser username

    Replace “username” with your desired username.

  2. Set a password for the new user:
    sudo passwd username
  3. Add the user to the wheel group to grant sudo privileges:
    sudo usermod -aG wheel username

Java Development Kit (JDK) Installation

The Java Development Kit (JDK) is essential for Android Studio, as it provides the necessary tools and libraries for developing Android applications. Android Studio requires a compatible JDK to function correctly.

  1. Install the recommended JDK version using the following command:
    sudo dnf install java-11-openjdk-devel

    Note: While Java 11 is mentioned here, check the Android Studio documentation for the most compatible version. Newer versions might be required or recommended.

  2. Verify the JDK installation by checking the Java version:
    java -version
  3. The output should display the installed Java version, confirming that the JDK is correctly installed.

Downloading Android Studio

With the prerequisites in place, the next step is to download Android Studio from the official website. Ensure you download the correct version for Linux to avoid compatibility issues.

Accessing the Official Android Studio Website

  1. Open your web browser and navigate to the Android Studio download page.
  2. Locate the Linux version of Android Studio.
  3. Click the download button to download the .tar.gz package.

Alternative Download Methods

You can also download Android Studio directly from the command line using wget. This method is useful for automated installations or when you prefer using the terminal.

  1. Open a terminal.
  2. Use wget to download the file:
    wget https://redirector.gvt1.com/edgedl/android/studio/install/2023.1.1.24/android-studio-2023.1.1.24-linux.tar.gz

    Note: Replace the URL with the actual download link from the Android Studio website.

  3. Verify the integrity of the downloaded file using checksum verification to ensure the file was not corrupted during download.

Extracting Android Studio

After downloading Android Studio, extract the .tar.gz file to a suitable location on your system. Extracting the files correctly is crucial for the proper functioning of Android Studio.

Using the Command Line

  1. Open a terminal.
  2. Navigate to the directory where you downloaded the .tar.gz file.
  3. Extract the file using the tar command:
    tar -xvzf android-studio-2023.1.1.24-linux.tar.gz

    Replace android-studio-2023.1.1.24-linux.tar.gz with the actual file name.

  4. Move the extracted directory to /opt/android-studio for better organization:
    sudo mv android-studio /opt

Setting up User Permissions

Ensure that the current user has the necessary permissions to access and modify the Android Studio files. Incorrect permissions can lead to issues when running the IDE.

  1. Change the ownership of the Android Studio directory to the current user:
    sudo chown -R $USER:$USER /opt/android-studio
  2. This command recursively changes the owner and group of the directory to the current user.

Running Android Studio

With Android Studio extracted and permissions set, you can now run the IDE. The initial launch involves several configuration steps to set up the environment.

Launching Android Studio

  1. Open a terminal.
  2. Navigate to the bin directory:
    cd /opt/android-studio/bin
  3. Execute the studio.sh script:
    ./studio.sh

Initial Configuration

Upon the first launch, Android Studio will prompt you to configure several settings. These settings are crucial for setting up the IDE according to your preferences.

  1. Choose “Do not import settings” for a fresh installation. This ensures a clean setup without inheriting settings from previous installations.
  2. Select the “Standard” installation type. This installs the most common settings and components, suitable for most users.
  3. Choose a UI theme (light or dark). Select a theme that is comfortable for your eyes.

Install Android Studio on CentOS Stream 10

SDK Component Setup

The Android SDK (Software Development Kit) provides the tools and libraries necessary for developing Android applications. Installing the correct SDK components is essential for building and running your apps.

  1. Understand the importance of the Android SDK. The SDK includes tools for compiling, debugging, and testing your apps.
  2. Accept the default SDK location or customize it. The default location is usually suitable, but you can change it if you prefer to store the SDK in a different directory.
  3. Install recommended SDK components and tools, such as the latest Android SDK Platform, Build-Tools, and Platform-Tools.
  4. Resolve potential download errors during setup. If you encounter errors, check your internet connection and try again. You may also need to configure proxy settings if you are behind a proxy server.

Configuring Android Studio

After the initial setup, further configuration is necessary to optimize Android Studio for your development workflow. Setting up the SDK, creating a desktop entry, and configuring environment variables are key steps.

Setting up the Android SDK

  1. Verify the SDK location in “Project Structure”. Go to “File > Project Structure > SDK Location” to ensure the path is correct.
  2. Install necessary SDK tools (Build-Tools, Platform-Tools). Use the SDK Manager (“Tools > SDK Manager”) to install these tools.

Creating a Desktop Entry

Creating a desktop entry allows you to launch Android Studio directly from your desktop environment, providing quick and easy access.

  1. Create a desktop entry for easy access.
  2. Use “Tools > Create Desktop Entry” in Android Studio.
  3. Alternatively, manually create a .desktop file in ~/.local/share/applications. Here’s an example:
     [Desktop Entry]
     Name=Android Studio
     Comment=Android Studio IDE
     Exec=/opt/android-studio/bin/studio.sh
     Icon=/opt/android-studio/bin/studio.png
     Terminal=false
     Type=Application
     Categories=Development;IDE;
  4. Save the file as android-studio.desktop and make it executable:
    chmod +x ~/.local/share/applications/android-studio.desktop

Environment Variables

Setting environment variables, such as ANDROID_HOME, is crucial for Android Studio to locate the SDK and other necessary tools. Correctly configured environment variables ensure that Android Studio functions smoothly.

  1. Set the ANDROID_HOME environment variable to point to the SDK directory.
  2. Edit ~/.bashrc or ~/.zshrc to set the variable:
    export ANDROID_HOME=/opt/android-studio/sdk
     export PATH=$PATH:$ANDROID_HOME/platform-tools
     export PATH=$PATH:$ANDROID_HOME/tools
  3. Make the environment variable permanent:
    source ~/.bashrc

    or

    source ~/.zshrc
  4. Verify that the environment variable is set correctly:
    echo $ANDROID_HOME

Troubleshooting Common Issues

During the installation and configuration process, you may encounter some common issues. This section provides solutions to help you troubleshoot and resolve these problems.

Dealing with Library Dependencies

Missing library dependencies can prevent Android Studio from running correctly. Identifying and installing these dependencies is essential for a smooth experience.

  1. Identify missing library errors. Look for error messages in the terminal or Android Studio that indicate missing libraries.
  2. Install required libraries using sudo dnf install <library-name>. For example:
    sudo dnf install glibc.i686

Resolving SDK Issues

Problems with the Android SDK can arise due to download failures or incorrect paths. Ensuring the SDK is correctly installed and configured is crucial.

  1. Handle SDK download failures by checking your internet connection and retrying the download.
  2. Fix incorrect SDK paths by verifying the SDK location in “Project Structure” and updating it if necessary.

Emulator Problems

The Android Emulator allows you to test your apps without a physical device. Configuring it correctly is essential for efficient testing.

  1. Configure the Android Emulator for optimal performance by allocating sufficient memory and CPU resources.
  2. Hardware acceleration setup (KVM installation):
    • Install KVM:
      sudo dnf install qemu-kvm libvirt virt-install
    • Start and enable the libvirtd service:
      sudo systemctl start libvirtd
      sudo systemctl enable libvirtd
  3. Troubleshoot emulator connection problems by ensuring that the emulator is properly configured and that your system can communicate with it.

Permissions Issues

File permission errors can prevent Android Studio from accessing necessary files. Ensuring correct user ownership and permissions is crucial.

  1. Address file permission errors by changing the ownership of the Android Studio files to the current user:
    sudo chown -R $USER:$USER /opt/android-studio
  2. Ensure correct user ownership of Android Studio files.

Firewall Configuration

A firewall can block Android Studio and emulator traffic, preventing them from functioning correctly. Configuring the firewall to allow necessary traffic is essential.

  1. Configure the firewall to allow Android Studio and emulator traffic.
  2. Use firewall-cmd to open necessary ports:
    sudo firewall-cmd --permanent --add-port=5037/tcp
    sudo firewall-cmd --permanent --add-port=5555-5585/tcp
    sudo firewall-cmd --reload

SELinux Considerations

Security-Enhanced Linux (SELinux) can restrict the actions of Android Studio. While disabling SELinux is not recommended, configuring it correctly can resolve potential issues.

  1. Temporarily disable SELinux for troubleshooting (not recommended for production):
    sudo setenforce 0
  2. Configure SELinux policies to allow Android Studio to function correctly (advanced). This involves creating custom SELinux policies to grant Android Studio the necessary permissions.

Creating a Sample Project

After installing and configuring Android Studio, creating a sample project is a great way to verify that everything is set up correctly. This section guides you through creating and running a simple Android app.

Starting a New Project

  1. Launch Android Studio and select “Create New Project”.
  2. Choose a project template (e.g., Empty Activity).
  3. Configure project settings (name, package name, location).

Running the App on the Emulator

  1. Create and configure an Android Virtual Device (AVD). Use the AVD Manager (“Tools > AVD Manager”) to create a virtual device.
  2. Run the sample app on the emulator. Click the “Run” button to build and run the app on the selected emulator.
  3. Troubleshoot build and deployment errors by checking the “Build” panel for error messages and resolving any issues.

Optimizing Android Studio Performance

To ensure a smooth and efficient development experience, optimizing Android Studio’s performance is crucial. This section provides tips on adjusting memory settings, disabling unnecessary plugins, and more.

Adjusting Memory Settings

  1. Increase the allocated memory for Android Studio in studio.vmoptions.
  2. Find the studio.vmoptions file. Its location varies depending on the operating system and Android Studio version.
  3. Edit the file and modify the -Xms and -Xmx values:
    -Xms2048m
    -Xmx4096m
  4. Restart Android Studio for the changes to take effect.

Disabling Unnecessary Plugins

  1. Identify and disable plugins that are not essential. Go to “File > Settings > Plugins” and disable any plugins that you don’t use regularly.
  2. Restart Android Studio after disabling plugins.

Using Gradle Offline Mode

  1. Enable offline mode to speed up build times when dependencies are already cached.
  2. Go to “File > Settings > Build, Execution, Deployment > Gradle” and check the “Offline work” box.
  3. Apply the changes and restart Android Studio.

Keeping Android Studio Updated

  1. Regularly update Android Studio to benefit from performance improvements and bug fixes.
  2. Check for updates by going to “Help > Check for Updates”.
  3. Install any available updates.

Congratulations! You have successfully installed Android Studio. Thanks for using this tutorial for installing Android Studio on CentOS Stream 10 systems. For additional help or useful information, we recommend you check the official Android Studio website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button