Android Code Studio provides a robust project management system that handles Gradle-based Android projects with full support for multi-module builds, dependency resolution, and workspace configuration.
The IProjectManager interface provides centralized project management:
interface IProjectManager { // Project directory access val projectDir: File val projectDirPath: String // Synchronization issues val projectSyncIssues: ProjectSyncIssues? // Project operations fun openProject(directory: File) fun openProject(path: String) // Setup with Tooling API suspend fun setupProject( project: IProject = Lookup.getDefault() .lookup(BuildService.KEY_PROJECT_PROXY)!! ) // Workspace access fun getWorkspace(): IWorkspace? fun requireWorkspace(): IWorkspace // File change notifications fun notifyFileCreated(file: File) fun notifyFileDeleted(file: File) fun notifyFileRenamed(from: File, to: File) // Lifecycle fun destroy()}
// Get root projectval rootProject = workspace.getRootProject()// Get all subprojectsval subprojects = workspace.getSubProjects()// Find specific project by pathval appProject = workspace.findProject(":app")if (appProject != null) { // Work with project}// Get project (throws if not found)try { val libProject = workspace.getProject(":library")} catch (e: IWorkspace.ProjectNotFoundException) { // Handle missing project}
// Find module containing a fileval file = File("/path/to/MainActivity.kt")val module = workspace.findModuleForFile(file)if (module != null) { println("File belongs to: ${module.path}")}// Check if file is a source fileval isSource = workspace.containsSourceFile(file.toPath())// Check if file is an Android resourceval isResource = workspace.isAndroidResource(file)
abstract class GradleProject { abstract val path: String abstract val name: String abstract val description: String abstract val projectDir: File abstract val buildDir: File abstract val buildScript: File abstract val tasks: List<TaskModel>}
class AndroidModule : ModuleProject { val namespace: String val buildVariant: String val androidProject: AndroidProject // Source sets val sourceSets: List<SourceSet> // Resources val resourceDirs: List<File> // Build configuration val compileSdkVersion: String val minSdkVersion: Int val targetSdkVersion: Int}
class JavaModule : ModuleProject { // Java-specific configuration val sourceCompatibility: String val targetCompatibility: String val sourceSets: List<SourceSet>}
Module Types
Android Code Studio supports various Gradle project types:
Android Application - Main app modules with manifest
The FileManager handles file operations and change notifications:
class FileManager { // File change tracking fun notifyFileCreated(file: File) fun notifyFileDeleted(file: File) fun notifyFileRenamed(from: File, to: File) // File operations fun readFile(file: File): String fun writeFile(file: File, content: String) fun createFile(file: File): Boolean fun deleteFile(file: File): Boolean}
interface IClasspathReader { fun readClasses(path: Path): Sequence<ClassInfo>}data class ClassInfo( val name: String, val packageName: String, val isPublic: Boolean, val isAbstract: Boolean, val isInterface: Boolean, val methods: List<MethodInfo>, val fields: List<FieldInfo>)
Android Code Studio supports Gradle version catalogs:
class VersionCatalogParser { fun parse(catalogFile: File): VersionCatalog}data class VersionCatalog( val versions: Map<String, String>, val libraries: Map<String, LibraryDependency>, val plugins: Map<String, PluginDependency>)
The project manager integrates with the Gradle Tooling API through BuildService:
interface BuildService { val isBuildInProgress: Boolean // Server status fun isToolingServerStarted(): Boolean fun metadata(): CompletableFuture<ToolingServerMetadata> // Project initialization fun initializeProject( params: InitializeProjectParams ): CompletableFuture<InitializeResult> // Task execution fun executeTasks( vararg tasks: String ): CompletableFuture<TaskExecutionResult> // Build cancellation fun cancelCurrentBuild(): CompletableFuture<BuildCancellationRequestResult>}
data class ActiveDocument( val file: File, val content: String, val version: Int)data class ActiveJavaDocument( val file: File, val content: String, val version: Int, val module: JavaModule) : ActiveDocument