在 Android Studio 中开发游戏
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以将 Android Studio 与 C/C++ 搭配使用,在 Android 平台上打造生动而精彩的游戏。
Android Studio 是用于开发 Android 应用的官方集成开发环境 (IDE)。它可为 C/C++ 编程语言和利用 Android 原生开发套件 (NDK)进行开发提供广泛支持,并且在多个操作系统上可用。
如果您已有 Microsoft Visual Studio 项目,并且主要在 Windows 上使用 C 或 C++ 编程语言进行开发,则可以改为使用针对 Microsoft Visual Studio 的 Android Game Development Extension。
管理项目
Android Studio 针对 C/C++ 代码的配置和管理集成了 CMake 支持。借助 CMake,您能够以模块化方式组织 C/C++ 项目的结构。Android Studio 的 Gradle 构建系统和 Android Gradle 插件使用 CMake 设置原生 C/C++ 代码模块的构建流程。
Android Studio 编辑器针对 C/C++ 代码提供强大的修改和索引功能。该编辑器的标准功能包括代码补全、语法重新设置格式、符号查找和预编译错误检查。
集成依赖项
Android Studio 的 Gradle 构建系统支持为您的项目声明本地或远程二进制文件依赖项。一个常见用例是,从 Maven 远程依赖项服务器中获取 Android Jetpack 等库。通过这些依赖项,您可以精确控制将依赖项的哪个版本集成到应用中。远程依赖项还有助于避免将不必要的文件提交到项目的版本控制系统。
在 Android Studio 中调试
Android Studio 提供了一个调试程序,可让您在模拟器或实体设备上调试游戏。Android Studio 调试程序支持 C/C++、Java 和 Kotlin,并使用 LLDB 来调试 C/C++。它针对所有语言提供程序断点和变量检查功能。使用 LLDB 调试 C/C++ 代码时,您可以设置硬件观察点。Android Studio 调试程序支持定义自定义数据类型渲染程序,以强化项目数据结构的显示。
在 Android Studio 中进行性能分析
Android Studio 包含各种性能分析工具,可帮助您衡量游戏的运行时性能。性能分析类别包括 CPU 使用率、内存用量、网络活动以及耗电量。有效使用性能分析工具可减少性能方面的小问题或游戏因为内存耗尽而崩溃的问题,这些问题会对玩家造成负面影响。降低游戏的耗电量可以避免由于温控调频而导致的性能问题。
Android Studio 提供了应用软件包分析工具,可让您检查 build 中的哪些内容占用了空间。这些工具在与 Play Asset Delivery 等功能搭配使用时,可帮助优化游戏的大小,并确保用户仅下载所需的数据。
如需详细了解 Android Studio,包括系统要求、下载链接和用户指南,请访问 Android Studio 页面。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Develop your game in Android Studio\n\nYou can use Android Studio with C/C++ to bring your game to life on Android.\n\n[Android Studio](/studio) is the official Integrated Development Environment\n(IDE) for Android app development. It includes extensive support for the C/C++\nprogramming language and development using the\n[Android Native Development Kit (NDK)](/ndk), and is available on multiple\noperating systems.\n\nIf you have existing Microsoft Visual Studio projects and develop primarily on\nWindows in C or C++, you can use the\n[Android Game Development Extension](/games/agde) for Microsoft Visual Studio\ninstead.\n\nManage your project\n-------------------\n\nAndroid Studio integrates CMake support for configuration and management of\nC/C++ code. CMake allows you to structure your C/C++ project in a modular\nfashion. Android Studio's Gradle build system and\n[Android Gradle plugin](/studio/releases/gradle-plugin)\nuse CMake to set up the build process for native C/C++ code modules.\n\nThe Android Studio editor has robust editing and indexing capabilities for C/C++\ncode. Standard features of the editor include code completion, syntax\nreformatting, symbol lookups, and pre-compile error checking.\n\nIntegrate dependencies\n----------------------\n\nAndroid Studio's Gradle build system supports declaring local or remote binary\ndependencies for your project. A common use case is pulling in libraries such as\n[Android Jetpack](/jetpack) from a Maven remote dependency server. These\ndependencies allow precise control of what version of a dependency is being\nintegrated into an app. Remote dependencies also help avoid committing\nextraneous files into your project's version control system.\n\nDebug in Android Studio\n-----------------------\n\nAndroid Studio provides a debugger that enables you to debug your game on either\nan emulator or a physical device. The Android Studio debugger supports C/C++,\nJava, and Kotlin, and uses [LLDB](https://lldb.llvm.org/) to debug\nC/C++. Program breakpoints and variable inspection are available for all\nlanguages. You can set hardware watchpoints when debugging C/C++ code using\nLLDB. The Android Studio debugger supports defining custom data type renderers\nfor enhanced display of project data structures.\n\nProfile in Android Studio\n-------------------------\n\nAndroid Studio includes profiling tools that help measure the runtime\nperformance of your game. Profiling categories include CPU usage, memory usage,\nnetwork activity and energy use. Effective use of profiling tools can reduce\nperformance hiccups or out of memory crashes in your game that negatively impact\nyour players. Reducing energy consumption of your game can avoid performance\nproblems due to thermal throttling.\n\nAndroid Studio features application package analysis tools that let you inspect\nwhat is taking up space in your build. These tools, when used in concert with\nfeatures such as Play Asset Delivery, help optimize the size of your game and\nensure your users don't download more data than is necessary.\n\nMore Information\n----------------\n\nFor more information on Android Studio, including system requirements, download\nlinks, and the user guide, visit the [Android Studio](/studio) page."]]