App Bundles for Google TV and Android TV

Posted by Josh Wentz, Product Management, Google TV

TLDR: Google TV and Android TV will be requiring Android App Bundles that are archivable starting in May 2023 to save storage for users.

Over the past few decades, TV has transformed from linear channel surfing to on-demand content with multi-app experiences. Today, over 10,000 apps are available on Android TV OS. While software has grown exponentially, TV hardware has remained limited in capacity compared to its phone counterparts. In 2022, smartphones often have a minimum storage size of 64GB, but smart TVs have an average of just 8GB. Less storage results in users having to uninstall apps, hindering their overall TV experience. To help with this problem and others, Android introduced App Bundles in Nov 2020.


What are Android App Bundles?

Android App Bundles” (AABs) are the standard publishing format on Google Play (phones, tablets, TVs, etc) that have replaced “Android Package Kits” (APKs). App Bundles are smaller, faster, fresher, and better than its precursor. Key benefits include:

  1. Smaller Download/Storage Size - App Bundles create an average of 20% total size savings compared to its equivalent APK counterpart by optimizing for each device.
  2. Less Likely to Uninstall - Since App Bundles enables users with the option to archive (which reclaims ~60% of app storage), users can keep these and more apps on their TV despite limited storage. A quick archive/unarchive user interface is built-in to the TV. Developers can also maintain state for a frictionless later return.
  3. Applicable to All Android Surfaces - App Bundles are helpful for all Android surfaces using the Google Play store including TV, phone, tablet, watch, auto, & more.
  4. Streamlined Delivery & Security - For easier delivery, a single artifact with all of your app's code & resources allows Play store to dynamically serve an optimized app for each device configuration. For greater security, developers can also reset the upload key if it’s lost or compromised.

What is new for TV?

With TV storage confined and users having an increasing appetite for more apps, Google TV and Android TV will be requiring App Bundles starting in May 2023. While this provides about 6-months to transition, we estimate that in most cases it will take one engineer about 3-days to migrate an existing TV app from Android Package Kit (APK) to Android App Bundle (AAB). While developers can configure archiving for their mobile apps, TV apps are required to be archivable so that all users and developers can benefit on storage-constrained TVs.

For TV apps not transitioned in time, Google may hide such apps from the TV surface. If you’re working on a brand new TV app, be sure to use Android App Bundles from the start!


How can TV apps transition?

Visit our Developer Guide to learn more about how to migrate to an Android App Bundle (AAB).

All told, App Bundles bring a delightful experience to both you as developers and your users, especially in the living room. Thank you for your partnership in creating immersive content and entertainment experiences for the future of TV.

Introducing Camera Viewfinder

Posted by Francesco Romano, Developer Relations Engineer, Androidhand holding a phoneOver the years, Android devices have evolved to include a variety of sizes, shapes, and displays, among other features. Since the beginning, however, taking pictures with your phone has been one of the most important use cases. Today, camera capabilities are still one of the top reasons consumers purchase a phone.

As a developer, you want to leverage camera capabilities in your app, so you decide to adopt the Android Camera Framework. The first use case you want to implement is the Preview use case, which shows the output of the camera sensor on the screen.

So you go ahead and create a CaptureSession using a surface as big as the screen size. As long as the screen has the same aspect ratio as the camera sensor output and the device stays in its natural portrait orientation, everything should be fine.

But what happens when you resize the window, unfold your device, or change the display or orientation? Well, in most cases, the preview may appear stretched, upside down, or incorrectly rotated. And if you are in a multi-window environment, your app may even crash.

Why does this happen? Because of the implicit assumptions you made while creating the CaptureSession.

Historically, your app could live in the same window for its whole life cycle, but with the availability of new form factors such as foldable devices, and new display modes such as multi-window and multi-display, you can't assume this will be true anymore.

In particular, let's see some of the most important considerations when developing an app targeting various form factors:

Let's examine some common pitfalls to avoid when developing an app targeting various form factors:

  • Don't assume your app will live in a portrait-shaped window. Requesting a fixed orientation is still supported in Android 13, but now device manufacturers may have the option of overriding an app request for a preferred orientation.
  • Don't assume any fixed dimension or aspect ratio for your app. Even if you set resizableActivity = "false", your app could still be used in multi-window mode on large screens (>=600dp).
  • Don't assume a fixed relationship between the orientation of the screen and the camera. The Android Compatibility Definition Document specifies that a camera image sensor "MUST be oriented so that the long dimension of the camera aligns with the screen's long dimension." Starting with API level 32, camera clients that query the orientation on foldable devices can receive a value that dynamically changes depending on the device/fold state.
  • Don't assume the size of the inset can't change. The new taskbar is reported to applications as an inset, and when used with gesture navigation, the taskbar can be hidden and shown dynamically.
  • Don't assume your app has exclusive access to the camera. While your app is in a multi-window state, other apps can obtain access to shared resources like camera and microphone.

While CameraX already handles most of the cases above, implementing a preview that works in different scenarios with Camera2 APIs can be complex, as we describe in the Support resizable surfaces in your camera app Codelab.

Wouldn’t it be great to have a simple component that takes care of those details and lets you focus on your specific app logic?

Say no more…

Introducing CameraViewfinder

CameraViewfinder is a new artifact from the Jetpack library that allows you to quickly implement camera previews with minimal effort. It internally uses either a TextureView or SurfaceView to display the camera feed, and applies the required transformations on them to correctly display the viewfinder. This involves correcting their aspect ratio, scale, and rotation. It is fully compatible with your existing Camera2 codebase and continuously tested on several devices.

Let’s see how to use it.

First, add the dependency in your app-level build.gradle file:

implementation "androidx.camera:camera-viewfinder:1.3.0-alpha01"

Sync your project. Now you should be able to directly use the CameraViewfinder as any other View. For example, you can add it to your layout file:

<androidx.camera.viewfinder.CameraViewfinder
  android:id="@+id/view_finder"
  app:scaleType="fitCenter"
  app:implementationMode="performance"
  android:layout_width="match_parent"
  android:layout_height="match_parent"/>

As you can see, CameraViewfinder has the same controls available on PreviewView, so you can choose different Implementation modes and scaling types.

Now that the component is part of the layout, you can still create a CameraCaptureSession, but instead of providing a TextureView or SurfaceView as target surfaces, use the result of requestSurfaceAsync().

fun startCamera(){
    val previewResolution = Size(width, height)
    val viewfinderSurfaceRequest =
ViewfinderSurfaceRequest(previewResolution, characteristics)
    val surfaceListenableFuture =
        cameraViewfinder.requestSurfaceAsync(viewfinderSurfaceRequest)

    Futures.addCallback(surfaceListenableFuture, object : FutureCallback<Surface> {
        override fun onSuccess(surface: Surface) {
            //create a CaptureSession using this surface as usual
        }
        override fun onFailure(t: Throwable) { /* something went wrong */}
    }, ContextCompat.getMainExecutor(context))
}


Bonus: optimized layouts for foldable devices

CameraViewFinder is ready-to-use across resizable surfaces, configuration changes, rotations, and multi-window modes, and it has been tested on many foldable devices.

But if you want to implement optimized layouts for foldable and dual screen devices, you can combine CameraViewFinder with the Jetpack WindowManager library to provide unique experiences for your users.

For example, you can choose to avoid showing full screen preview if there is a hinge in the middle of the screen, or if the device is in “book” or “tabletop” mode. In those scenarios, you can have the viewfinder in one portion of the screen and the controls on the other side, or you can use part of the screen to show the last pictures taken. Imagination is the limit!

The sample app is already optimized for foldable devices and you can find the code to handle posture changes here. Have a look!

Great internet can help your business bloom

Our small business series continues with Santiago Salazar of Austin’s Flor Keeps on how quality internet has literally helped his family business grow. For more of the Flor Keeps story, you can also check out the Google Fiber YouTube channel


How It Started


Flor Keeps is a floral company located in Austin, Texas, specializing in real flowers that last over one year. None of our flowers require any water, & should only be kept indoors!

Thumbnail

Inspired by my father’s flower business over the last 10 years, I believed it was time to shift the mold of what flowers could look like, come from, and how long they can actually last. We quickly came to recognize that this city embodied qualities that are rare to find anywhere else. Austin radiates a sense of creativity, encourages risk-takers to be themselves, & poses an emphasis on always giving back to the community. The food, the scenery _ and most importantly — the people have elevated what it means to love what you do & where you live. 

The goal for Flor Keeps is to bring the Austin community together & reinvent our wildest visions, ideas, & passions. If there’s anything about this city, it’s that we dare to be different. We push the boundaries of the ordinary & we fall together, knowing we successfully gave it everything.

How We Succeed


Flor Keeps currently operates in three avenues: Retail, Mass Market, and E-Commerce.

We owe all of our success in those outlets to the internet. Without it, we would primarily depend on only “word of mouth” to share the story of our products! Since the beginning of Flor Keeps, we have been able to reach our customers in the Austin-area through Google searches, online delivery platforms, or simply through our social media posts. Whether it’s attending to walk-in customers, responding quickly to online orders, or fulfilling orders to our partner supermarkets, we streamline our business through the use of our Google Fiber high-speed internet – 

thankfully!


The Good Stuff


At Flor Keeps, we donate a portion of our proceeds to an Austin-based non-profit organization called WellAware. WellAware implements lasting clean water systems to drive development and empower communities in East Africa.

We wanted to contribute to a cause that not only helps people in need, but also makes sense for our brand to collaborate with. Our flowers at Flor Keeps don’t require water, but people do. The techniques we use to extend the lifetime of our product go hand in hand with water conservation. Therefore, we are able to create an initiative to help those that really do need this resource!

So take a moment to use your internet to come visit us (and maybe find the perfect gift this holiday season)!

Posted by Santiago Salazar, Founder, Flor Keeps