{"id":348071,"date":"2025-09-13T15:57:47","date_gmt":"2025-09-13T20:57:47","guid":{"rendered":"https:\/\/michigandigitalnews.com\/index.php\/2025\/09\/13\/building-ai-first-android-experiences-with-gemini-using-jetpack-compose-and-firebase\/"},"modified":"2025-09-13T15:57:47","modified_gmt":"2025-09-13T20:57:47","slug":"building-ai-first-android-experiences-with-gemini-using-jetpack-compose-and-firebase","status":"publish","type":"post","link":"https:\/\/michigandigitalnews.com\/index.php\/2025\/09\/13\/building-ai-first-android-experiences-with-gemini-using-jetpack-compose-and-firebase\/","title":{"rendered":"Building AI first Android Experiences with Gemini using Jetpack Compose and Firebase"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div>\n<meta content=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgJMX_7Zv1fLkW3owXCRM0kLzDEN_kiDo_uHBN29LCk4SNgCy3bey3c2TKV7oX7fxOQn2eecilvQMPeVhB235z6SbAZY3Lckwn5q7Yla-uk0lYzdiJ04Z5LwLvixJde-zRTyvciHBmTXrhqAHqLAp_fahvV-LIroy2u4Tb9qrQ4SJ5g6vYaAGfgTZFpz3M\/s1600\/androidify-promo.gif\" name=\"twitter:image\"\/><br \/>\n<img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgJMX_7Zv1fLkW3owXCRM0kLzDEN_kiDo_uHBN29LCk4SNgCy3bey3c2TKV7oX7fxOQn2eecilvQMPeVhB235z6SbAZY3Lckwn5q7Yla-uk0lYzdiJ04Z5LwLvixJde-zRTyvciHBmTXrhqAHqLAp_fahvV-LIroy2u4Tb9qrQ4SJ5g6vYaAGfgTZFpz3M\/s1600\/androidify-promo.gif\" style=\"display: none;\"\/><\/p>\n<p><em>Posted by Rebecca Franks \u2013 Developer Relations Engineer, Tracy Agyemang &#8211; Product Marketer, and Avneet Singh \u2013 Product Manager<\/em><\/p>\n<p>Androidify is our new app that lets you build your very own Android bot, using a selfie and AI. We walked you through <a href=\"https:\/\/android-developers.googleblog.com\/2025\/05\/androidify-how-androidify-leverages-gemini-firebase-ml-kit.html\" target=\"_blank\" rel=\"noopener\">some of the components earlier this year<\/a>, and starting today it\u2019s available on the <a href=\"https:\/\/androidify.com\" target=\"_blank\" rel=\"noopener\">web<\/a> or as an <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.android.developers.androidify\" target=\"_blank\" rel=\"noopener\">app on Google Play<\/a>. In the new Androidify, you can upload a selfie or write a prompt of what you\u2019re looking for, add some accessories, and watch as AI builds your unique bot. Once you\u2019ve had a chance to try it, come back here to learn more about the AI APIs and Android tools we used to create the app. Let&#8217;s dive in!<\/p>\n<p><iframe title=\"Androidify: Turning selfies into a cute Android bot with AI\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/5r712vuHSEA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2><span style=\"font-size: x-large;\">Key technical integrations<\/span><\/h2>\n<p>The Androidify app combines powerful technologies to deliver a seamless and engaging user experience. Here&#8217;s a breakdown of the core components and their roles:<\/p>\n<h3><span style=\"font-size: large;\">AI with Gemini and Firebase<\/span><\/h3>\n<p>Androidify leverages the <a href=\"https:\/\/firebase.google.com\/products\/firebase-ai-logic\" target=\"_blank\" rel=\"noopener\">Firebase AI Logic SDK<\/a> to access Google&#8217;s powerful Gemini and Imagen* models. This is crucial for several key features:<\/p>\n<li><b>Image validation<\/b>: The app first uses Gemini 2.5 Flash to validate the user&#8217;s photo. This includes checking that the image contains a clear, focused person and meets safety standards before any further processing. This is a critical first step to ensure high-quality and safe outputs.<\/li>\n<li><b>Image captioning<\/b>: Once validated, the model generates a detailed caption of the user&#8217;s image. This is done using structured output, which means the model returns a specific JSON format, making it easier for the app to parse the information. This detailed description helps create a more accurate and creative final result.<\/li>\n<li><b>Android Bot Generation<\/b>: The generated caption is then used to enrich the prompt for the final image generation. A specifically fine-tuned version of the Imagen 3 model is then called to generate the custom Android bot avatar based on the enriched prompt. This custom fine-tuning ensures the results are unique and align with the app&#8217;s playful and stylized aesthetic.<\/li>\n<p>The Androidify app also has a &#8220;Help me write&#8221; feature which uses Gemini 2.5 Flash to create a random description for a bot&#8217;s clothing and hairstyle, adding a bit of a fun &#8220;I&#8217;m feeling lucky&#8221; element.<\/p>\n<p><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"gif showcasing the help me write button\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjvnPIK_7VbHYpq0sE-ARX-uD6SK2mFNTwAdCcu4D4wWKjW7InvHuvCsIE2oHRZepvjtKspmZutU8SOhkmWiiwip-C4Cg8eZezBTlDthZVkMq-gLd_yeYjYvabJIwD6b6fKqhLyPKV646X37RfVZh1iJbEKZ7QkkbimLy8FIBTxvYhr8orpRB5K1JghLWE\/s1600\/help_me_write.gif\" width=\"80%\"\/><\/div>\n<p><\/image><\/p>\n<h3><span style=\"font-size: large;\">UI with Jetpack Compose and CameraX<\/span><\/h3>\n<p>The app&#8217;s user interface is built entirely with Jetpack Compose, enabling a declarative and responsive design across form factors. The app uses the latest <a href=\"https:\/\/m3.material.io\/blog\/building-with-m3-expressive\" target=\"_blank\" rel=\"noopener\">Material 3 Expressive design<\/a>, which provides delightful and engaging UI elements like new shapes, motion schemes, and custom animations.<\/p>\n<p>For camera functionality, CameraX is used in conjunction with the ML Kit Pose Detection API. This intelligent integration allows the app to automatically detect when a person is in the camera&#8217;s view, enabling the capture button and adding visual guides for the user. It also makes the app&#8217;s camera features responsive to different device types, including foldables in tabletop mode.<\/p>\n<p>Androidify also makes extensive use of the latest Compose features, such as:<\/p>\n<li><b>Adaptive layouts<\/b>: It&#8217;s designed to look great on various screen sizes, from phones to foldables and tablets, by leveraging <span style=\"color: #0d904f; font-family: courier;\">WindowSizeClass<\/span> and reusable composables.<\/li>\n<li><b>Shared element transitions<\/b>: The app uses the new Jetpack Navigation 3 library to create smooth and delightful screen transitions, including <a href=\"https:\/\/www.youtube.com\/watch?v=0moEXBqNDZI&amp;ab_channel=AndroidDevelopers\" target=\"_blank\" rel=\"noopener\">morphing shape animations<\/a> that add a polished feel to the user experience.<\/li>\n<li><b>Auto-sizing text<\/b>: With Compose 1.8, the app uses a new parameter that automatically adjusts font size to fit the container&#8217;s available size, which is used for the app&#8217;s main &#8220;Customize your own Android Bot&#8221; text.<\/li>\n<p><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"chart illustrating the behavior of Androidify app flow\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEirLpuA-LS-j5QnwfY7nZd92TJQCodpI1xFLl8HNg0-oH6SXKzwFCF7d_2UB_ttTCEJfWjIBXzz8J8hqimdyEuWkGqTBppREQgkILmrdGHS4_D2L7cgxipx6BOjmps2Dg4Qho5Pug8ERSliGva0A1mX9MbFfMgAU2_KHG29RII8TfWMBvTaKdB2qYna2ZA\/s1600\/image3.png\"\/><\/div>\n<p><imgcaption><center><em><b>Figure 1.<\/b> Androidify Flow<\/em><\/center><\/imgcaption><\/image><\/p>\n<h2><span style=\"font-size: x-large;\">Latest updates<\/span><\/h2>\n<p>In the latest version of Androidify, we\u2019ve added some new powerful AI driven features.<\/p>\n<h3><span style=\"font-size: large;\">Background vibe generation with Gemini Image editing<\/span><\/h3>\n<p>Using the <a href=\"https:\/\/developers.googleblog.com\/en\/introducing-gemini-2-5-flash-image\/\" target=\"_blank\" rel=\"noopener\">latest Gemini 2.5 Flash Image model<\/a>,  we combine the Android bot with a preset background \u201cvibe\u201d to bring the Android bots to life.<\/p>\n<p><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"a three-part image showing an Android bot on the left, text prompt in the middle reads A vibrant 3D illustration of a vibrant outdoor garden with fun plants. the flowers in thisscene have an alien-like qulaity to them and are brightly colored. the entire scene is rendered with a meticulous mixture of rounded, toy-like objects, creating a clean, minimalist aesthetic..., and image on the right is the Android bot from the first image stanging in a toy like garen scene surrounded by brightly colored flowers. A whitre picket fence is in the background, and a red watering can sits on the ground next to the driod bot\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiRA6H0Gokf2hA79rO6TK-m5GGyqK69k7KwLo4H7g0901W2QFsdrabmbKtoAkdjLRYD47Jwr6jL7egbFvos-9wbygeM38yoGmeiXBBG8zdeCid_IkNvi1w7QJdtQjxrOLWMJz_luO_YYvnFEVuzjWtGr5wrfu_fmXgdhEhPo5aJpV9uhwimCEDteg4yWqE\/s1600\/image5.png\" width=\"100%\"\/><\/div>\n<p><imgcaption><center><em><b>Figure 2.<\/b> Combining the Android bot with a background vibe description to generate your new Android Bot in a scene<\/em><\/center><\/imgcaption><\/image><\/p>\n<p>This is achieved by using <a href=\"https:\/\/firebase.google.com\/docs\/ai-logic\/generate-images-gemini?api=dev\" target=\"_blank\" rel=\"noopener\">Firebase AI Logic<\/a> &#8211; passing a prompt for the background vibe, and the input image bitmap of the bot, with instructions to Gemini on how to combine the two together.<\/p>\n<p><!--Kotlin--><\/p>\n<div style=\"background: rgb(248, 248, 248); border: 0px; overflow: auto; width: auto;\">\n<pre style=\"background-color: white; color: black; font-family: monospace; font-weight: 400;\"><span style=\"color: #000088; font-weight: 400;\">override<\/span> <span style=\"color: #000088; font-weight: 400;\">suspend<\/span> <span style=\"color: black; font-weight: 400;\"><span style=\"color: #000088; font-weight: 400;\">fun<\/span> <span style=\"color: #660066; font-weight: 400;\">generateImageWithEdit<\/span><span style=\"color: #660066; font-weight: 400;\">(\n        image: <span style=\"color: #660066; font-weight: 400;\">Bitmap<\/span>,\n        backgroundPrompt: <span style=\"color: #660066; font-weight: 400;\">String<\/span> = <span style=\"color: #008800; font-weight: 400;\">\"Add the input image android bot as the main subject to the result... with the background that has the following vibe...\"<\/span>,\n    )<\/span><\/span>: Bitmap {\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(\n            modelName = <span style=\"color: #008800; font-weight: 400;\">\"gemini-2.5-flash-image-preview\"<\/span>,\n            generationConfig = generationConfig {\n                responseModalities = listOf(\n                    ResponseModality.TEXT,\n                    ResponseModality.IMAGE,\n                )\n            },\n        )\n\t  <span style=\"color: #880000; font-weight: 400;\">\/\/ We combine the backgroundPrompt with the input image which is the Android Bot, to produce the new bot with a background<\/span>\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> prompt = content {\n            text(backgroundPrompt)\n            image(image)\n        }\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> response = model.generateContent(prompt)\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> image = response.candidates.firstOrNull()\n            ?.content?.parts?.firstNotNullOfOrNull { it.asImageOrNull() }\n        <span style=\"color: #000088; font-weight: 400;\">return<\/span> image ?: <span style=\"color: #000088; font-weight: 400;\">throw<\/span> IllegalStateException(<span style=\"color: #008800; font-weight: 400;\">\"Could not extract image from model response\"<\/span>)\n    }<\/pre>\n<\/div>\n<p><iframe title=\"Androidify Gemini 2.5\" width=\"1200\" height=\"900\" src=\"https:\/\/www.youtube.com\/embed\/CctukhqDm9U?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>Sticker mode with ML Kit Subject Segmentation<\/h2>\n<p>The app also includes a \u201cSticker mode\u201d option, which integrates the <a href=\"https:\/\/developers.google.com\/ml-kit\/vision\/subject-segmentation\" target=\"_blank\" rel=\"noopener\">ML Kit Subject Segmentation<\/a> library to remove the background on the bot. You can use &#8220;Sticker mode&#8221; in apps that support stickers.<\/p>\n<p><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"backgroud removal\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjZdQjt0lJq2JJPzJlptnXza1KqVaRzuNREIYRTVMv-tc-Vy190LVq3nzj4W5eP9eD1aiO9U4lN6iuKe7hyoGCMKSz5j73riMBozlzNmIBWvWoT5d8Y72wZ5bytU4iME9Kd7p_C2EfEhwgGJgobItL2SocfdeBc1WN71LcEI67w8MUE-jJKOA7bBEAZXIE\/s1600\/image3.png\" width=\"100%\"\/><\/div>\n<p><imgcaption><center><em><b>Figure 3.<\/b> White background removal of Android Bot to create a PNG that can be used with apps that support stickers<\/em><\/center><\/imgcaption><\/image><\/p>\n<p>The code for the sticker implementation first checks if the Subject Segmentation model has been downloaded and installed, if it has not &#8211; it requests that and waits for its completion. If the model is installed already, the app passes in the original Android Bot image into the segmenter, and calls <span style=\"color: #0d904f; font-family: courier;\">process<\/span> on it to remove the background. The <span style=\"color: #0d904f; font-family: courier;\">foregroundBitmap<\/span> object is then returned for exporting.<\/p>\n<p><!--Kotlin--><\/p>\n<div style=\"background: rgb(248, 248, 248); border: 0px; overflow: auto; width: auto;\">\n<pre style=\"background-color: white; color: black; font-family: monospace; font-weight: 400;\"><span style=\"color: #000088; font-weight: 400;\">override<\/span> <span style=\"color: #000088; font-weight: 400;\">suspend<\/span> <span style=\"color: black; font-weight: 400;\"><span style=\"color: #000088; font-weight: 400;\">fun<\/span> <span style=\"color: #660066; font-weight: 400;\">generateImageWithEdit<\/span><span style=\"color: #660066; font-weight: 400;\">(\n        image: <span style=\"color: #660066; font-weight: 400;\">Bitmap<\/span>,\n        backgroundPrompt: <span style=\"color: #660066; font-weight: 400;\">String<\/span> = <span style=\"color: #008800; font-weight: 400;\">\"Add the input image android bot as the main subject to the result... with the background that has the following vibe...\"<\/span>,\n    )<\/span><\/span>: Bitmap {\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(\n            modelName = <span style=\"color: #008800; font-weight: 400;\">\"gemini-2.5-flash-image-preview\"<\/span>,\n            generationConfig = generationConfig {\n                responseModalities = listOf(\n                    ResponseModality.TEXT,\n                    ResponseModality.IMAGE,\n                )\n            },\n        )\n\t  <span style=\"color: #880000; font-weight: 400;\">\/\/ We combine the backgroundPrompt with the input image which is the Android Bot, to produce the new bot with a background<\/span>\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> prompt = content {\n            text(backgroundPrompt)\n            image(image)\n        }\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> response = model.generateContent(prompt)\n        <span style=\"color: #000088; font-weight: 400;\">val<\/span> image = response.candidates.firstOrNull()\n            ?.content?.parts?.firstNotNullOfOrNull { it.asImageOrNull() }\n        <span style=\"color: #000088; font-weight: 400;\">return<\/span> image ?: <span style=\"color: #000088; font-weight: 400;\">throw<\/span> IllegalStateException(<span style=\"color: #008800; font-weight: 400;\">\"Could not extract image from model response\"<\/span>)\n    }<\/pre>\n<\/div>\n<p>See the <span style=\"color: #0d904f ;font-family: courier;\"><a href=\"https:\/\/github.com\/android\/androidify\/blob\/main\/core\/network\/src\/main\/java\/com\/android\/developers\/androidify\/ondevice\/LocalSegmentationDataSource.kt\" target=\"_blank\" rel=\"noopener\">LocalSegmentationDataSource<\/a><\/span> for the full source implementation<\/p>\n<h2><span style=\"font-size: x-large;\">Learn more<\/span><\/h2>\n<p>To learn more about Androidify behind the scenes, take a look at the new <a href=\"https:\/\/developers.google.com\/solutions\/learn\/androidify\" target=\"_blank\" rel=\"noopener\">solutions walkthrough<\/a>, <a href=\"https:\/\/github.com\/android\/androidify\" target=\"_blank\" rel=\"noopener\">inspect the code<\/a> or try out the experience for yourself at <a href=\"http:\/\/androidify.com\" target=\"_blank\" rel=\"noopener\">androidify.com<\/a> or <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.android.developers.androidify\" target=\"_blank\" rel=\"noopener\">download the app on Google Play<\/a>.<\/p>\n<p><image><\/p>\n<div style=\"text-align: center;\"><img decoding=\"async\" alt=\"moving demo of Androidfiy app\" border=\"0\" id=\"imgCaption\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgJMX_7Zv1fLkW3owXCRM0kLzDEN_kiDo_uHBN29LCk4SNgCy3bey3c2TKV7oX7fxOQn2eecilvQMPeVhB235z6SbAZY3Lckwn5q7Yla-uk0lYzdiJ04Z5LwLvixJde-zRTyvciHBmTXrhqAHqLAp_fahvV-LIroy2u4Tb9qrQ4SJ5g6vYaAGfgTZFpz3M\/s1600\/androidify-promo.gif\" width=\"80%\"\/><\/div>\n<p><\/image><\/p>\n<p>*Check responses. Compatibility and availability varies. 18+.<\/p>\n<\/div>\n<p>[ad_2]<br \/>\n<br \/><a href=\"http:\/\/android-developers.googleblog.com\/2025\/09\/androidify-ai-gemini-android-jetpack-compose-firebase-camerax.html\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Posted by Rebecca Franks \u2013 Developer Relations Engineer, Tracy Agyemang &#8211; Product Marketer, and Avneet Singh \u2013 Product Manager Androidify is our new app<\/p>\n","protected":false},"author":1,"featured_media":347692,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[146],"tags":[],"_links":{"self":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/348071"}],"collection":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/comments?post=348071"}],"version-history":[{"count":0,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/posts\/348071\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media\/347692"}],"wp:attachment":[{"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/media?parent=348071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/categories?post=348071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michigandigitalnews.com\/index.php\/wp-json\/wp\/v2\/tags?post=348071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}