Google AI Studio 推出全栈安卓开发:一句话做出带云数据库、Google 登录和 Gemini 的 App,直接装进自己手机
原文链接: https://developers.googleblog.com/build-full-stack-android-apps-with-gemini-in-google-ai-studio/ 来源: developers.googleblog.com 发现于: 小互 · AI 解读站 · 2026/11/18 说明: 本文由 AIHot汪 自动聚合(原文即中文,未翻译)。正文取自小互 AI 解读
全文 Markdown · 会员
作者:Google for Developers11-18 · 约 9 分钟
你写的一句话做一个安卓健身教练应用:用 Gemini 生成每天的个性化训练,语音念出动作提示,训练记录用 Google 登录、在多台设备间保存。
9:41●●● 每日训练林 今天 · 20 分钟核心力量,Gemini 按你的目标排好 周一 拉伸 已同步周二 有氧 已同步 从 Google Play 安装
云数据库记录跨设备同步 Google 登录只看得到自己的 安全调用 Gemini密钥不进安装包 Google Play装进自己的手机
示意图:一句话进去,Agent 把应用需要的后台一样样接上,最后送进你自己的 Google Play。

Google 给 AI Studio 的安卓应用制作补上了后台。AI Studio 是 Google 的网页版 AI 开发工作台,用一段话描述就能生成应用;它此前已经能做原生安卓应用(用安卓主流的 Kotlin 语言和 Jetpack Compose 界面框架写成),在浏览器里的云端模拟器预览。这次配上 Gemini 4 Carbon(主攻持续多天的长编程任务)和 Hydrogen(Gemini 4 里主打快和省的一档),它能从一句提示词做出带数据存储、用户登录和 AI 功能的完整安卓应用,几分钟内发到你自己的 Google Play 个人库。
后台这部分靠的是 Firebase,Google 给 App 开发者准备的现成后台服务:数据库、登录、AI 调用都有现成的一套,不用自己搭服务器。
这次主要更新:
- **数据存进云端:**自动开好 Cloud Firestore 云数据库,按你的数据结构写好安全规则;换台设备数据还在,断网时先存在本机,联网后自动同步。
- **Google 账号登录:**自动配好 Firebase Authentication,每个用户只能读写自己的数据。
- **安全调用 Gemini:**API 密钥不写进安装包,由 Firebase AI Logic 在服务器端保管,Firebase App Check 核实请求来自你那个没被改过的正版应用。
- **发到自己的 Google Play:**普通 Google 账号就能把应用发到个人库,手机上点几下装好,不花钱;前提是手机能正常使用 Google Play。
- **模拟器更快、更清楚、能出声:**启动延迟明显降低,画面能切到 1200p 高清,浏览器里直接听得到应用的声音;一键截图发给 Agent 改界面,支持自定义字体,底层改用官方 Android CLI 构建。
AI Studio 刚开始支持做安卓应用时,Firestore、登录和 App Check 都还列在「即将推出」里。那时做出的应用,数据只能存在本机这一次会话里,演示一下可以,自己天天用不行。这次补上的是用户看不见的那一半:数据放哪、谁能看、调用 AI 的钥匙藏哪、怎么装到手机上。一句「帮我做个 App」最容易把这些略过去,出了事又最难收拾。
72 秒演示:先用一段话描述一个叫 Wayword 的东京旅行短语卡应用;再追加一句「加上实时翻译和朗读,并在登录后保存我的短语本」,Agent(这里用的是 Gemini 4 Hydrogen)随即弹出「启用集成」,一键打开数据存储和 Gemini。做好的卡片点 Normal 或 Slow,用正常或慢速朗读日语;最后扫二维码,从 Google Play 装到手机。
一句话里,Agent 读出了要配哪些后台
你描述的应用只要用得上长期保存、用户登录或者 AI 生成,AI Studio 里负责干活的 Build Agent 会自己认出来,先问你一句;你确认后,它把后台开好,再把 Kotlin 代码接上。
Agent 从一句话里认出三种需要 示意图 提示词里没写任何技术名词,Agent 照样知道要开哪些服务。 提示词做一个家庭菜谱 App:全家用 Google 账号登录,拍下食材,让 AI 出菜谱主意,购物清单大家共用、实时同步。
要登录→Firebase Authentication · Google 账号登录,配上按用户划分的权限 要用 AI→Firebase AI Logic + App Check · 安全调用 Gemini,密钥不进安装包 要存、要同步→Cloud Firestore + 安全规则 · 云端数据库,多台设备看到同一份
Agent:要为这个应用启用这些集成吗?启用✓ 已启用 接着它改好 Kotlin 代码:加上 Firebase 的依赖清单,写好数据层和 AI 层。
登录、AI 调用、数据存储这三样后台都由 Firebase 提供。启用集成的弹窗上,数据存储写着起步免费,Gemini 写着大部分 AI 功能起步免费;发到自己的 Google Play、装到手机上测试也不花钱。
为什么非得靠 Firebase?安卓应用在 AI Studio 里只有客户端,也就是装在手机上的那部分,没有一台属于它的服务器:网页应用能用的服务器端密钥保管、多人实时协作,安卓应用都用不了。Firebase 补的就是这个缺口,数据库、登录和 AI 调用的「服务器那一侧」由它来担,你不用自己搭服务器。
数据:平板上开始,手机上接着用
Agent 会开一个 Cloud Firestore 数据库(Google 的云端数据库,数据按一条条「文档」存放),装好 Firebase 的安卓开发包,再按你的数据结构生成安全规则。效果是:用户在平板上用到一半,拿起手机能从刚才的地方接着用;手机没网时数据先缓存在本机,网络恢复后自动同步上去。
同一份训练记录,换台设备还在 示意图 以前数据只存在本机这次会话里,换一台设备,什么都看不到。
平板
周一 拉伸周二 核心周三 有氧
Firestore
周一 拉伸周二 核心周三 有氧
手机
在线断网 周一 拉伸周二 核心周三 有氧先存在本机**已补传
- 平板上记下两次训练,存进云端
- 拿起手机,从刚才的地方接着用
- 手机断网,新记录先缓存在本机
- 网络恢复,自动补传,三处一致
登录:每个人只看得到自己的
应用需要个人资料或者私人空间时,Agent 会配好 Firebase Authentication,让用户用 Google 账号登录,同时配上按用户划分的权限规则:每个人只能读写属于自己的文档。这道规则在数据库那一侧把关,不靠手机上的应用自觉。
三次请求,规则怎么判 示意图 **规则:**已经登录,而且这条记录的主人(ownerId)就是你,才放行。 训练记录:小林 · 周一拉伸小林 · 周二核心小周 · 周二跑步
小林 已登录要看 小林 · 周一拉伸✓ 放行 小林 已登录要看 小周 · 周二跑步✗ 拦下 不是你的 没登录的人要写进 一条新记录✗ 拦下 没登录
AI:调用 Gemini 的钥匙,留在服务器上
应用要调用 Gemini,得带上 API 密钥。它相当于你在 Google 那里的账户钥匙,谁拿着它发请求,用的都是你的额度。最省事的写法是把密钥直接写进代码、打进 APK(安卓安装包)。可安装包会发到每个用户手里,谁都能把它拆开,把里面的字符串一条条翻出来。把密钥写进去,就像把保险柜密码印在发出去的每一张传单上。
现在 Agent 一碰到要调用 Gemini 的应用,就自动换一条路:Firebase AI Logic 在中间当代理,密钥只留在服务器端;Firebase App Check 再给每个请求验明正身,只放行来自你那个正版、没被改动过的应用的请求。
调用 Gemini 的钥匙放在哪 示意图
✗ 把密钥写进安装包
APK 安装包代码里写着 AIza••••
发到每台手机谁都能下载一份
有人拆开它把密钥翻出来抄走
拿去调用 Gemini用的是你的额度
✓ 现在:密钥留在服务器端
你的应用安装包里没有密钥 App Check核实是正版、没被改过 Firebase AI Logic代理,密钥只放在这里 Gemini收到请求,返回结果
被改过的应用、脚本想冒充你的应用 App Check:拦下拿不到通行凭证,请求到不了 Gemini
这道核验对做应用的人是自动的:在浏览器模拟器里调试时它就在工作,发到 Google Play 后自动换成 Google 的防欺诈服务(Google Fraud Defense)来核验,不用你另外配置。Firebase AI Logic 还默认给每个用户设了调用频率上限,上限可以自己调。
Agent 写出来的代码长什么样
后台开好以后,Agent 会加上 Firebase BoM(一份统一管理 Firebase 各个库版本的清单),再把数据层和 AI 层的 Kotlin 代码写好。下面是健身应用里「生成一份训练计划并存档」的那段,每块下面是它在做什么:
生成训练计划并存进数据库(Kotlin) Build Agent 生成的示例代码,只调整了换行。
<span class="cm">// Generated by Google AI Studio Build agent using Firebase AI Logic & Cloud Firestore</span>
<span class="kw">class</span> WorkoutRepository(context: Context) {
<span class="kw">private val</span> generativeModel <span class="kw">by</span> lazy {
Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel(<span class="st">"gemini-4-hydrogen"</span>)
}
1通过 Firebase AI Logic 拿到 gemini-4-hydrogen 模型。这里一个密钥都没有,调用由 Firebase 后台代办。
<span class="kw">private val</span> db = FirebaseFirestore.getInstance(
context.applicationContext
.getString(R.string.firestore_database_id))
2连上 Agent 开好的那个 Firestore 数据库,数据库编号存在应用的资源文件里。
<span class="kw">suspend fun</span> generateAndSaveWorkout(goal: String, uid: String) {
<span class="kw">val</span> response = generativeModel.generateContent(<span class="st">"Create a 20-minute workout for: $goal"</span>)
3让 Gemini 按用户的目标写一份 20 分钟的训练计划。
<span class="kw">val</span> workout = hashMapOf(
<span class="st">"ownerId"</span> to uid,
<span class="st">"goal"</span> to goal,
<span class="st">"plan"</span> to (response.text ?: <span class="st">""</span>),
<span class="st">"createdAt"</span> to FieldValue.serverTimestamp()
)
4打包成一条记录:ownerId 写上当前用户,按用户划分的权限规则据此判断这条记录归谁;时间取服务器时间。
db.collection(<span class="st">"workouts"</span>)
.add(workout).await()
}
}
5存进 workouts(训练记录)这个集合,等写入完成再返回。 站内旧文 · 代码里那个模型 Google 发布 Gemini 4 Hydrogen:比 3.8 Flash 还快 2.5 倍,编程得分从 18.2% 涨到 57% 示例代码和演示视频里干活的都是 Hydrogen:Gemini 4 家族里主打快和省的一档,速度、跑分和价格在这篇里。 阅读 →
Firebase 的英文讲解视频:在 AI Studio 里用 Firebase AI Logic 和 App Check 做安全的 AI 安卓应用。点封面就地播放,也可以去 YouTube 看。
在浏览器里调到满意
手机界面好不好用,得边看边改。浏览器里的安卓模拟器(跑在云上、把画面传到浏览器里的虚拟手机)和 Agent 的工具链这次一起升级:
- **启动更快,能切 1200p 高清:**模拟器启动延迟明显降低,改完代码很快就能看到效果;工具栏上的 HD 开关能把画面切到 1200p,细看间距、动画和密集的排版。
- **能听到声音:**模拟器里的声音直接从浏览器放出来。做语音对话(Gemini Live API)、文字转语音(TTS)教练、带音效的游戏和播放器类应用,都不用离开 AI Studio 去测。
- **自定义字体:**跟 Agent 说想要什么字体,它会自己下载、配置,套用到整套 Compose 主题上。
- **底层换成官方 Android CLI:**Agent 用 Google 官方的安卓命令行工具搭项目结构、查最新的安卓文档、跑 Gradle 构建,构建出错更少,也撑得住更复杂的多屏应用。
模拟器工具栏最下面的 HD 开关:点亮后,画面切到 1200p 高清,方便细看间距和密集的排版。
一张截图,省掉一大段描述
界面上哪里不对,用文字描述常常要写好几段。现在点模拟器工具栏上的「Take a screenshot」,当前画面会直接附进提示词;你只要说想怎么改,比如卡片内边距收紧一点、对比度调高、工具栏重新对齐,Gemini 就看着这张图去改 Kotlin 界面代码。
截图一点,直接交给 Agent 示意图
每日训练 今天 · 核心力量20 分钟 · 6 个动作开始
HD
① 点工具栏上的截图按钮 → ② 附进提示词,说一句要改什么
模拟器截图 卡片内边距收紧一点,「开始」按钮和标题左对齐。
Gemini 对着截图改好 Kotlin 界面代码,模拟器自动刷新。✓ 已改好
不截图的话,同一件事你得这样写:「第一张卡片四周空白太大,标题离左边大概有一个字那么宽,下面那个绿色的按钮又比标题再往右缩进了一截……」
装进自己的手机
模拟器再好,也替代不了真机。过去把一个刚做好的安卓应用装到自己手机上,要么打开手机的 USB 调试、用数据线连电脑,要么在本地自己管理签名密钥库,要么去开一个完整的开发者后台账号。
现在 Google Play 接进了 AI Studio。在发布面板里点几下设好 Play 账号,就能把应用发到你自己的 Google Play 个人库;AI Studio 在后台打包、签名 .aab 文件(安卓应用包),你在手机上打开 Google Play 就能下载运行。用的是普通 Google 账号,不花钱。
从做好到装进自己手机
以前:三条路,各有门槛
- 数据线 + USB 调试打开手机的开发者选项,连电脑传安装包
- 自己管签名密钥库给安装包签名的私钥文件,要在本地保管好
- 开 Play 开发者账号一次性 25 美元注册费,填完开发者资料,才能发内部测试
现在:在 AI Studio 里走完
- 1发布面板里设好 Play 账号点几下,普通 Google 账号就行
- 2后台打包、签名AI Studio 生成签好名的 .aab 安卓应用包
- 3进你的 Google Play 个人库只有你自己看得到
- 4手机上直接下载打开 Google Play 安装,像装别的应用一样
个人库是 Google Play 不久前新开的一块。据 TechCrunch 和 9to5Google 报道,里面的应用只有你自己看得到,不出现在商店的搜索和列表里,但仍要遵守 Google Play 的现有政策;Google 还计划让你把应用私下分享给少数亲友,哪天真火了,过完审核也能转成正式上架。按当时的报道,个人库先在美国等部分市场推出,面向 18 岁以上的用户。
现在就能试,也有做不到的
这些功能正在 AI Studio 里陆续开放。打开 AI Studio 的 Build,在工作区顶部选 Android,再输入提示词。可以拿下面两句试试,中文直接写也行:
两句可以直接试的提示词
健身教练做一个安卓健身教练应用:用 Gemini API 生成个性化的每日训练,用语音念出动作提示,并用 Cloud Firestore 和 Google 登录,在多台设备间保存训练记录。"Build an Android workout coach app that uses the Gemini API to generate personalized daily routines, reads cues aloud with audio, and saves workout history across devices using Cloud Firestore and Google Sign-In." 家庭菜谱做一个全家协作的菜谱安卓应用,用自定义的衬线字体:用户用 Google 账号登录,拍下食材照片让 Gemini 出菜谱主意,共用的购物清单在 Firestore 里同步。"Create a collaborative family recipe Android app with custom serif typography where users sign in with Google, snap photos of ingredients to generate recipe ideas with Gemini, and sync shared grocery lists in Firestore."
也有边界:
- 浏览器里的模拟器用不了 Google 登录这类 Play 服务,也用不了摄像头,这些功能要装到真机上试;
- 安卓应用只有客户端,需要服务器端运行的功能(服务器端密钥管理、多人协作、Google Workspace 接口)目前只有网页应用能用;
- 只用 Kotlin 和 Jetpack Compose,不支持 Java、XML 布局,也不支持 C/C++ 原生代码;
- 只做手机和平板,不支持 Wear OS 手表和 Android TV;
- 项目可以下载成 ZIP,拿到 Android Studio 里接着开发。 站内旧文 · 网页应用那一边 Google AI Studio 接入 Google Maps API:免绑卡一句话生成 3D 城市漫游、路线规划与门店搜索应用 网页应用有服务器端,AI Studio 会把地图密钥直接存进后台的 secrets。对照着看,就明白安卓应用为什么要靠 Firebase 来保管密钥。 阅读 →
把这些拼起来看,AI Studio 做安卓应用这件事,从「做出一个能在模拟器里跑的样子」,走到了「自己和家人能天天用、换了手机数据还在」。想给自己做个小工具的人,以前最劝退的几步:开数据库、写权限规则、藏好密钥、签名装机,现在都由 Agent 先做好,等你点头。权限规则是 Agent 按它对你需求的理解生成的,应用里存的东西越私密,越值得自己点开生成的规则看一眼。 来源Build full-stack Android apps with Gemini in Google AI StudioMike Taylor-Cai(Google for Developers)·2026-11-17·查看主材料延伸Build native Android apps in Google AI Studio(Android Developers 博客)·Build Android apps in Google AI Studio(Gemini API 文档)·Gemini API using Firebase AI Logic(Firebase 文档)·Google Play now lets anyone build private, vibe-coded apps that run on Android(TechCrunch)·Google Play adding 'personal library' to access your vibe-coded Android apps(9to5Google)·Build secure AI Android apps in Google AI Studio with Firebase AI Logic & App Check(Firebase YouTube)本站说明两段演示视频和视频封面来自 Google;主演示视频在稿件目录放了 1280 宽的压缩版。
原文版权归原作者,这里只供对照阅读。 看原网页 ↗
Build full-stack Android apps with Gemini in Google AI Studio
Google AI Studio now lets developers build, test, and ship full-stack Kotlin Android apps from a single prompt—complete with Cloud Firestore, Firebase Authentication, Firebase AI Logic, a faster HD emulator with audio, visual screenshot debugging, and direct publishing to your personal Google Play library.
NOV. 17, 2026
Google AI Studio, with Gemini 4 Carbon and Hydrogen, now enables you to build and ship full-stack, Android applications and publish to the Play Store in minutes. You can now go from a single prompt to a production-ready Kotlin Android app complete with data persistence, user sign-in, and AI features. Simply bring your idea and the Google AI Studio Build agent takes care of the entire setup. From configuring your database to securely calling the Gemini API, you can rapidly build and test on your own device directly from the Play Store at no cost.
Alongside full-stack Firebase backend provisioning, a major wave of upgrades is rolling out across the Android development workflow in Google AI Studio. Developers can now iterate in a faster, high-definition (HD) Android emulator with real-time audio output, send one-click emulator screenshots directly to the coding agent for visual UI changes, and style apps with custom fonts.
What’s new at a glance
Here is what is launching today for Android app development in Google AI Studio:
- Full-stack persistence and sign-in: Automatically provision a Cloud Firestore database with Security Rules and Google Sign-In so user data syncs across sessions and devices.
- Secure Gemini API calls: Call Gemini models from your Android app without exposing API keys in your APK, protected by Firebase AI Logic and Firebase App Check.
- Personal Google Play publishing: Ship Android apps directly to your personal Google Play library with a standard Google account and install them on your phone in clicks.
- Faster, high-definition emulator with audio: Spin up Android emulators with lower latency, toggle HD video streaming, and test real-time audio output directly in your browser.
- One-click screenshot to agent: Capture a live frame from the running emulator with a single click and attach it to your prompt to guide visual UI edits.
- Custom fonts and Android CLI integration: Style Jetpack Compose UIs with custom typography, backed under the hood by the official Android CLI for reliable project scaffolding and builds.
Go full-stack in minutes with Cloud Firestore, Authentication, and Firebase AI Logic
Previously, Android apps generated in AI Studio were limited to local session storage. Now, when your prompt describes an Android app that needs persistent storage, user sign-in, or generative AI features, the Google AI Studio Build agent proactively detects those requirements. With your confirmation, the agent provisions the backend and wires up your Kotlin codebase automatically:
- Persistent, cross-device data with Cloud Firestore: The Build agent provisions a Cloud Firestore database, configures the Firebase Android SDKs, and generates Firebase Security Rules tailored to your data model. Users can start a session on an Android tablet and pick up right where they left off on their phone, with offline caching that syncs automatically when connectivity returns.
- Identity management with Firebase Authentication: When your app needs user profiles or private workspaces, the agent configures Firebase Authentication with Google Sign-In and pairs it with per-user authorization rules so users can only read and write their own documents.
- Server-side credential protection with Firebase AI Logic: Hardcoding API keys inside a client APK risks credential extraction. When your Android app calls Gemini models, the Build agent automatically configures Firebase AI Logic and enforces Firebase App Check using Google Fraud Defense (formerly reCAPTCHA Enterprise). Credentials stay protected server-side, and App Check verifies that incoming requests originate from your authentic, untampered app—both in the browser emulator and on Google Play.
Under the hood, the Build agent automatically adds the Firebase Bill of Materials (BoM) and generates clean, idiomatic Kotlin code for your data and AI layers:
// Generated by Google AI Studio Build agent using Firebase AI Logic & Cloud Firestore
class WorkoutRepository(context: Context) {
private val generativeModel by lazy {
Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel("gemini-4-hydrogen")
}
private val db = FirebaseFirestore.getInstance( context.applicationContext.getString(R.string.firestore_database_id))
suspend fun generateAndSaveWorkout(goal: String, uid: String) {
val response = generativeModel.generateContent("Create a 20-minute workout for: $goal")
val workout = hashMapOf(
"ownerId" to uid,
"goal" to goal,
"plan" to (response.text ?: ""),
"createdAt" to FieldValue.serverTimestamp()
)
db.collection("workouts").add(workout).await()
}
}
Kotlin
Iterate faster with an HD, audio-enabled emulator and visual debugging
Building great mobile interfaces requires a tight visual and interactive feedback loop. Both the in-browser Android emulator and the Build agent's toolchain include new capabilities to help you inspect, hear, and refine your app in real time:
- Faster startup and 1200p HD streaming: Emulators now boot with significantly lower latency so you can test code changes rapidly. Use the HD toggle in the emulator toolbar to switch the stream to 1200p high definition, making it easy to inspect fine Jetpack Compose spacing, animations, and dense layouts.
- Real-time audio output: Hear live audio from the Android emulator directly in your browser. You can build and test voice-driven Gemini Live API companions, text-to-speech (TTS) coaches, sound-enabled games, and media apps without leaving Google AI Studio.
- One-click screenshot to agent: Describing a visual layout issue in text can take paragraphs. Click Take a screenshot in the emulator toolbar to capture the live app screen and attach it directly to your prompt. Point out the adjustment you want—such as tightening card padding, fixing contrast, or realigning a toolbar—and Gemini updates the Kotlin UI code with full visual context.
- Custom fonts support: Give your app a distinct visual identity by asking the agent for custom fonts. The Build agent automatically downloads, configures, and applies your chosen typography across your Compose theme.
- Powered by the Android CLI under the hood: Behind the scenes, the Google AI Studio Build agent now uses the official Android CLI to scaffold project structures, query current Android documentation, and execute Gradle builds, reducing build errors and supporting more complex multi-screen architectures.
Ship straight to your phone with Google Play
Testing in an emulator accelerates iteration, but nothing replaces running your app on a physical device. Historically, installing a newly built Android app onto a phone required enabling USB debugging cables, managing signing keystores locally, or setting up a full developer console account.
With Google Play integrated directly into Google AI Studio, you can set up a Play account in a few clicks from the publish panel and publish your app straight to your personal Google Play library. Google AI Studio builds and signs the Android App Bundle (.aab) behind the scenes, so you can immediately download and run your custom Android app on your phone directly from Google Play.
What’s next: Start building your Android app today
All of these features are rolling out in Google AI Studio today. To get started, open Google AI Studio Build, select the Android chip at the top of the workspace, and try one of these prompts:
"Build an Android workout coach app that uses the Gemini API to generate personalized daily routines, reads cues aloud with audio, and saves workout history across devices using Cloud Firestore and Google Sign-In."
"Create a collaborative family recipe Android app with custom serif typography where users sign in with Google, snap photos of ingredients to generate recipe ideas with Gemini, and sync shared grocery lists in Firestore."
Explore the Google AI Studio documentation and Firebase Android documentation to learn more, try building your own full-stack Android app at aistudio.google.com/apps, and share what you build on X with @GoogleDevs, @GoogleAIStudio, and @AndroidDev.
Previous
Next
↑ 正文结束 ✓ 本篇全文免费开放
读完还有疑问?会员每天能问小互 30 次,每句带出处;还有一份按你口味挑好的每日 AI 日报。 成为会员 $59/年按月 $6.99
7 天内不满意全额退 · 看会员能多什么 →
📮 新解读每晚进邮箱
读完觉得有用?留个邮箱,每晚一封当天的新解读,随时退订。