frameworks/base 里面大多是 Java 代码,VS Code 打开后,你需要告诉它对应的 classpath。这个可以通过创建一个 build.gradle 解决。
# frameworks/base/build.gradle
# 其他的自己按需加入
apply plugin: 'java'
sourceSets {
main {
java {
srcDirs 'core/java'
srcDirs 'graphics/java'
}
}
}
-
在 Mac 上,使用 Shift + Command + P 打开 Command Pallette。找到 C/Cpp: Edit configurations。然后就会打开一个 c_cpp_properties.json 文件。
-
配置c_cpp_properties.json文件
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include",
"/usr/include",
"${workspaceFolder}/frameworks/av/include",
"${workspaceFolder}/frameworks/av/media/libmedia/include"
],
"defines": [
"__ANDROID__"
],
"browse": {
"path": [
"${workspaceFolder}",
"${workspaceFolder}/**",
"/usr/local/include",
"/usr/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}