AIDEGen (Android IDE Generator) is designed to automate the project setup process so that developers can work on Java or C/C++ projects in popular IDE environments. Developers no longer need to manually configure an IntelliJ project, such as all project dependencies. It is a command line tool that provides the following functionality:
-
Configure Android Studio or IntelliJ project files and resolve relevant module dependencies.
-
Launches the IDE for the specified subproject or build target, i.e. frameworks/base or Settings.
-
Launches the IDE for the specified folder containing the build target, i.e. cts.
-
Automatically configure JDK and Android coding styles for IntelliJ.
AIDEGen's readme can be viewed online documentation or source code location: tools/asuite/aidegen/README.md
- prerequisites:
IDE installation, choose your favorite IDE, including Android Studio, IntelliJ IDEA, Eclipse, CLion and VS Code.
Set up the Android development environment.
$ source build/envsetup.sh && lunch <TARGET>
- Basic usage:
Example of generating and starting an IntelliJ project for the framework and Settings:
$ 'aidegen <module_name>... <module_path>...'
Example to generate and launch IntelliJ project for framework and
Settings:
$ aidegen Settings framework
$ aidegen packages/apps/Settings frameworks/base
$ aidegen packages/apps/Settings framework
$ 'aidegen <module> -i s'
Example to generate and launch Android Studio project for framework:
$ aidegen framework -i s
- Optional parameters:
Developers can also use the following optional parameters with the AIDEGen command.aidegen --help
Options | Long options | describe |
---|---|---|
-d |
--depth |
The depth of modules referenced by the source. |
-i |
--ide |
Start the IDE type, j=IntelliJ s=Android Studio e=Eclipse c=CLion v=VS Code |
-p |
--ide-path |
Specify the user's IDE installation path. |
-n |
--no_launch |
Don't start the IDE. |
-r |
--config-reset |
Resets all saved configurations of AIDEGen. |
-s |
--skip-build |
Skip building jars or modules. |
-v |
--verbose |
Displays DEBUG level logging. |
-a |
--android-tree |
Generate the entire Android source tree project file for the IDE. |
-e |
--exclude-paths |
Exclude directories in the IDE. |
-l |
--language |
Start the IDE using a specific language, j=java c=C/C++ r=Rust |
-h |
--help |
Show help message and exit. |
- Use AIDEGen to import AOSP source code to AndroidStudio
Source code location: development/tools/idegen//README.md, online documentation
Build AIDEGen command:
# 加载编译脚本(在源码根目录下)
source build/envsetup.sh && lunch <TARGET>
# 编译idegen生成idegen.jar(在源码根目录下)
# make idegen 或
mmm development/tools/idegen
# 执行idegen.sh脚本 (可能需要sudo权限)
# 执行完毕后源码根目录下会生成 android.iml 和 android.ipr 两个as工程配置文件
development/tools/idegen/idegen.sh
#打开Android Studio导入源码
点击"Open an existing Android Studio project"选项,找到并选中刚刚生成的"android.ipr"文件
After completing the above four steps, you will find that three new files (maybe two) have appeared in the source code root directory.
-
android.iml (records the modules, dependencies, SDK versions, etc. contained in the project, similar to an XML file)
-
android.ipr (project specific configuration, code and dependent lib and other information, similar to Visual Studio's sln file)
-
android.iws (mainly contains some personal configuration information, it may not be generated after performing the above operations, this does not matter, it will be automatically generated after opening the project once)
"android.iml" and "android.ipr" are generally "read-only" attributes. We recommend that you change these two files to readable and writable. Otherwise, you may be unable to change some project configurations. To save, just execute the following two commands.
sudo chmod 777 android.iml
sudo chmod 777 android.ip
Configuration class tags of the "android.iml" file:
(1) sourceFolder: Indicates that the directory is added to the index.
(2) excludeFolder: Indicates that the directory will not be included in the index.
(3) orderEntry: Indicates that it belongs to the project reference jar package.
Android is big, so IDEA requires a lot of memory
(1) Add "-Xms1g -Xmx5g" to your VM options in "Help > Edit Custom VM"
(2) Increase the file size limit in "Help -> Edit custom properties" , increase "idea.max.intellisense.filesize=100000"
and make sure to restart the IDE for the new settings to take effect.