“Keep It Simple Silly” AOSP Development!! code access and editing

Narendra Harny
Make Android
Published in
4 min readDec 28, 2023

It’s been a long time since editing the AOSP source code was done on the Linux Operating system using Vim editor which is certainly slower and not easier when Vim commands are not handy. Sometimes fixing code indentations becomes a bit tricky if the edited code is large and again we need to go back to any other text editor also the code walk-through is a bit difficult with Linux shell and vim.

It’s been a long time since AOSP developers wanted to access and edit AOSP source code easily and speed up the way of development for AOSP customization. Android AOSP developers may have this need because they want to download the AOSP source code in their local machine to build the AOSP source and generate the AOSP system images to flash the experimental hardware board.

So when it comes to walking through the AOSP source and editing the code it might not be that convenient and faster to manually search the source file or edit it in a traditional way using shell and vim editor or text editors and file explorer.

Using the following support scripting we can quickly load the whole AOSP source into Android Studio and it will not hand the Android Studio this way.

Sync AOSP in the local machine in Android Studio, IntelliJ or Eclipse.

AOSP provided a package to help for generating the .ipr which is IDEgen, which contains a series of scripts that will build sources and generate the .ipr file.

Of course, we need to build the AOSP source before this task because there are several generated classes (AIDL stubs, resource files, etc.) that are needed to satisfy many of the cross-references.

$ source build/envsetup.sh

$ lunch aosp_x86-eng #(or pick your suitable lunch target)

$ make

$ mmm development/tools/idegen/

$ development/tools/idegen/idegen.sh

It might take some time!! sit back and relax. The output of the IDEgen build script will be.

.classpath (Eclipse)

android.ipr (IntelliJ / Android Studio)

android.iml (IntelliJ / Android Studio)

Android Studio & IntelliJ

File → Open → Select <android.ipr> for Android Studio & Intellij.

Once you open the “.ipr” as an Android project in Android Studio or IntelliJ. It will take some time to sync so wait for some time and the AOSP source will be ready with maximum possible cross reference for code redirection.

Eclipse

For Eclipse, you must import the AOSP root as a Java Project.

Mostly in organizations AOSP sync on the local machine may be restricted on the local machine due to security reasons. Even without syncing the source code on the local machine, we have “SSH remote connection” features available which can help us access the full source code on IDEs being stored on the server machines. Many times there is a chance that you may not have a powerful laptop computer which can hold resources like CPU and RAM so we need to depend on powerful home PCs or Servers in the corporation.

AOSP on the server machine in V S Code

Precondition!! To use this approach we need to have an SSH connection established in as client and Host between the Local machine and Server Machine.

Enabling SSH connections to a remote server in Visual Studio Code (VS Code) can be a convenient way to work on remote projects. Here’s a step-by-step guide on how to set up SSH in VS Code.

Prerequisites:

1. Ensure you have the Remote Development extension pack installed in VS Code. This pack includes the necessary extensions for working with remote servers.

2. Have an SSH key pair (public and private key) ready. If you don’t have one, you can generate it using the ssh-keygen command.

Remote Connection

#Step 1: Install the Remote Development Extension Pack

  1. Open VS Code.
  2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.
  3. Search for “Remote Development” and install the extension pack.

#Step 2: Configure SSH

  1. Open the Command Palette in VS Code by pressing Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS).
  2. Type “Remote-SSH: Open Configuration File” and select it. This will open the ssh_config file where you can configure your SSH connections.

#Step 3: Configure SSH Connection

  1. In the ssh_config file, you can define your SSH connections as mentioned in the be code block, Save and close the ssh_config file.
Host my-remote-server // Choose a name for your remote server.
HostName your-server-address-or-ip // Server ip
User your-ssh-username // Your SSH username
IdentityFile /path/to/your/private/key // The path to your private SSH key

#Step 4: Connect to the Remote Server

  1. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
  2. Type “Remote-SSH: Connect to Host” and select it.
  3. Choose the server you defined in your ssh_config file (e.g., “my-remote-server”).

VS Code will connect to your remote server via SSH. You may be prompted to enter your SSH key’s passphrase or password.

Step 5: Work on the Remote Server

Once connected, you can work on your remote server within VS Code as if you were working locally. You can open files, edit code, and use extensions just like you would on your local machine.

Several other IDEs also support remote SSH connections to access and work on source code located on remote machines. I have not tried with all we can try and share the experience of how to do it. I will be happy to extend this article to any other IDEs to make it easy.

VS Code Tips and Tricks

Thanks for Reading!

Please comment with questions and suggestions!! If this blog is helpful for you then hit Please hit the clap! Follow on Medium, Connect on LinkedIn, Follow on Insta and send emails if any discussion is needed on the same topic on copy email.

--

--

Narendra Harny
Make Android

Connect on https://medium.com/make-android | Write On, Android AOSP & Applications | Python | DevOps | Java | C++ | Kotlin | Shell | Linux | Android Auto | IVI