Using AIDEGen for AOSP development

AIDEGen, presumably a shorthand for “Android IDE (helper) Generator”, is a tool in the AOSP source tree that allows working on system applications from within an IDE like Android Studio that is normally only configured for non-platform app development.

For more official information, see the AIDEGen README: Android 10, Android master.

The system-reserved com.android.internal, SystemUI etc. classes are not exposed via the Android SDK for app developers, but rather listed in the platform application’s Android.mk or Android.bp makefiles. The aidegen tool can bridge the gap from makefiles to IDEs and generate configuration files with the resolved paths of the system classes and libraries from a working AOSP tree.

aidegen can also create configs for C++ IDEs, but we will not cover them in this article

Build AIDEGen:

. build/envsetup.sh
lunch aosp_x86-userdebug
m aidegen
On Android Q, AIDEGen chokes on non-ASCII Java source files. You can patch the fix in or use Android R or master. That is why we will not be using the prebuilt aidegen shipped in Q and instead build aidegen-dev.

The generated aidegen-dev binary will be in out/host/linux-x86/bin/aidegen-dev.

Run it (you must be cd’d to the root of the Android tree):

# Usage:
aidegen-dev [OPTIONS] $package_or_path
# Where $package can be a module name or $path can be, well, a path
# E.g.:
aidegen-dev -i s SystemUI
# Full command documentation:
aidegen-dev --help
You will need to run aidegen anew every time the Android.mk-based source files are changed, e.g. when you switch branches for a security patch or if you changed the Android.mk or Android.bp file of your platform-level app yourself.

A more practical example:

python3 out/soong/host/linux-x86/bin/aidegen-dev \
    -n \ # Do not launch IDE
    -s \ # Skip building jar/modules that create java files at build
    packages/apps/Camera2

Full command reference of optional arguments, as of Android Q:

-h, --help            show help message and exit
-d {0,1,2,3,4,5,6,7,8,9}, --depth {0,1,2,3,4,5,6,7,8,9}
                      The depth of module referenced by source.
-v, --verbose         Display DEBUG level logging.
-i IDE, --ide IDE     Launch IDE type:
                        j: IntelliJ,
                        s: Android Studio,
                        e: Eclipse.
-p IDE_INSTALLED_PATH, --ide-path IDE_INSTALLED_PATH
                      IDE installed path.
-n, --no_launch       Do not launch IDE.
-r, --config-reset    Reset all saved configurations,
                      e.g., preferred IDE version.
-s, --skip-build      Skip building jar or modules that create
                      java files in build time, e.g. R/AIDL/Logtags.
-a, --android-tree    Generate whole Android source tree
                      project file for IDE.

A good recommendation is to add the generated files to your .gitignore:

#.gitignore

# Eclipse project
**/.classpath
**/.project

# IntelliJ project
**/.idea
**/*.iml
**/*.ipr
**/lib
**/gen

See also:

Published by

Edit source on Github