Category Archives: Android Developers Blog

An Open Handset Alliance Project

Moving Android Studio and Android Emulator to 64-bit versions

Posted by Sam Lin, Product Manager, Android

With Project Marble, the Android Studio team focused our efforts on making the fundamental features and flows of the Integrated Development Environment (IDE) rock-solid. Performance is an underlying tenant to delivering a high quality IDE. To this end, we are sharpening our product focus and we will only support 64-bit operating systems going forward. Using Android Studio with an 64-bit operating systems enables efficient access to memory for both the IDE and the Android Emulator, and overall leads to a better development experience. While this change will not affect most Android Studio users, this change does have an impact if you use 32-bit versions of Microsoft® Windows®. To aid in this transition for those developers using 32-bit versions of Microsoft Windows, we want to give you details on the upcoming depreciation timeline plus steps to take to be ready for this upcoming change.

Timeline

To minimize the impact of this change towards exclusively supporting 64-bit operating systems, we will first deprecate the 32-bit version. During the depreciation phase, both Android Studio and the Android Emulator will continue to work but the products will not receive new feature updates. During this transition period you can still download the product from the Android Studio web site. After one year, we will officially end product support and will remove the 32-bit product version download links. Note, if you have the 32-bit version of Android Studio previously installed during this period then the product should continue to work, but we will not provide a link for you to re-download the product. The exact dates for the depreciation and end-of-support period are in the table below:

Supported 32-bit Product Version Deprecation from End of Support on
Android Studio IDE 3.6 December 31, 2019 December 31, 2020
Android Emulator 28.0.25 Jun 30, 2019 December 31, 2020

Advantages of a 64-bit development environment

There are a few advantages to using a 64-bit version of Android Studio, which include:

  • Performance - The IDE can perform better because it can access more than 4GB of memory. The increase in memory especially provides a better experience when you are working on a large project.
  • 64-bit App Support - You can build both 32-bit and 64-bit versions of apps if your app uses C/C++ native code. Testing on both architectures can help you to get ready for the 64-bit requirement on Google Play which starts on August 1st, 2019.
  • Testing on Emulators - Both the 32-bit and 64-bit Android Emulator system images are supported by the 64-bit version of the Android Emulator. This flexibility makes it easier to test your app in different Android environments with one development machine.

Next steps

To recap, before ending support for the 32-bit version of Android Studio, we want to inform you in advance, provide guidance, and allow for a one-year lead time to help you migrate to a 64-bit operating system. You can still use 32-bit versions of Android Studio, but be mindful that these version will not receive future updates. Therefore, if you want to migrate we suggest you start planning early so that you can continue to get the latest product updates and take advantage of the performance improvements of a 64-bit development environment.

Android Q Beta 4 and Final APIs!

Posted by Dave Burke, VP of Engineering

AndroidQ logo

Last month at Google I/O we talked about what’s new for Android developers, from new features in Android Q to the latest in Kotlin and Jetpack.

With Android Q, we highlighted three themes: innovation, security and privacy, and digital wellbeing. We want to help you take advantage of the latest new technology -- 5G, foldables, edge-to-edge screens, on-device machine learning, and more -- while making sure users' security, privacy, and wellbeing are always a top priority.

We also talked about how we’re going increasingly Kotlin-first, and continuing to expand Jetpack with new libraries like CameraX, Jetpack Security and Jetpack Compose -- a modern reactive-style UI toolkit for Android that takes advantage of Kotlin. If you missed the livestream for the keynotes or tech sessions, make sure to check out the full playlist of Android and Play sessions.

Today we’re releasing Beta 4 with the final Android Q APIs and official SDK -- the time is now to get your apps ready for the final release later in the summer!

You can get Beta 4 today on Pixel devices by enrolling here. If you're already enrolled and received the Beta 3 on your Pixel device, you'll automatically get the update to Beta 4. Partners participating in the Android Q Beta program will also be updating their devices to Beta 4 over the coming weeks.

To get started with Android Q Beta, visit developer.android.com/preview.

What’s in Beta 4?

The Beta 4 update includes the latest Android Q system images for Pixel and Android Emulator, along with the final Android Q developer APIs (API level 29), the official API 29 SDK, and updated build tools for Android Studio. Together, these give you everything you need to test your apps for compatibility with Android Q and build with Android Q features and APIs.

To get started, download the official API 29 SDK and tools into the stable release of Android Studio 3.4, or for the latest Android Q support update to Android Studio 3.5 Beta. Then follow these instructions to configure your environment, and see the release notes for known issues.

Make your apps compatible with Android Q!

With the developer APIs finalized and release candidate builds coming soon, it’s critical for all Android developers to test their current apps for compatibility with Android Q. We recommend getting started as soon as possible.

Just install your current app from Google Play onto an Android Q Beta device or emulator, then test. As you work through the flows, your app should run and look great and handle all of the Android Q behavior changes properly. Watch for impacts from privacy changes, gestural navigation, changes to dynamic linker paths for Bionic libraries, and others.

Make sure that you test with the Android Q privacy features, such as the new location permissions, restrictions on background activity starts, changes to data and identifiers, and other key privacy features. See the privacy checklist to get started, and review the behavior changes doc for more areas to test.

Android Developers YouTube channel UI on landscape mode.

You can use the updated Android Emulator to test your apps for compatibility.

If you plan to update your platform targeting to API 29, also make sure to test with scoped storage, location permission for wireless scans, and permission for fullscreen intents. You can read about other changes that could affect apps here.

It's also important to test for uses of restricted non-SDK interfaces and move to public SDK or NDK equivalents instead. Watch for logcat warnings that highlight these accesses and use the StrictMode method detectNonSdkApiUsage() to catch them programmatically.

Last, make sure to fully test the libraries and SDKs in your app to make sure they work as expected on Android Q and follow best practices for privacy, performance, UX, data handling, and permissions. If you find an issue, try updating to the latest version of the SDK, or reach out to the SDK developer for help. You can also report SDK compatibility issues here.

When you’ve finished your testing and made any updates, we recommend publishing your compatible app right away. This lets Android Beta users test the app now, and helps you deliver a smooth transition to users as they update to Android Q.

We realize that supporting these changes is an investment for you too, and we're working to minimize the impact on your apps and be responsive to your input as we move toward the final release in the coming months.

Enhance your app with Android Q features and APIs

When you're ready, dive into Android Q and learn about the new features and APIs that you can use in your apps. Android Q features can help you engage users, give them more control and security, and even improve your app's performance.

mobile device notification window

Android Q provides system-suggested replies and actions in notifications.

For example, you can deliver seamless, edge-to-edge experiences on today’s innovative devices by optimizing for foldables and supporting gestural navigation in your app. To engage more users, try supporting Dark Theme, suggested replies and actions in notifications, sharing shortcuts, and settings panels.

Google Maps app closes to display home screen with ocean aerial image

Gestural navigation lets you offer an edge-to-edge experience in your apps.

If your app manages IoT devices over Wi-Fi, try the new network connection APIs for functions like configuring, downloading, or printing. If your app manages Wi-Fi internet connections, try the network suggestion APIs as an easier way to surface preferred Wi-Fi networks, without needing to request location permission.

If you use the camera, learn about dynamic depth format. For media, you can use AV1 for video streaming and HDR10+ for high dynamic range video. For speech and music streaming, you can use Opus encoding, and for musicians, a native MIDI API is available.

Dynamic Depth lets you offer specialized blurs and bokeh options in your app.

To support captioning or gameplay recording, enable audio playback capture -- it’s a great way to reach more users and get your app noticed. If your app uses power intensively, try using the new thermal API to optimize app performance based on device temperature.

BiometricPrompt is now the preferred way to support fingerprint auth on modern devices, so all developers using fingerprint or other biometric auth should move to using this API as soon as possible. To make the transition easy, use the backwards-compatible BiometricPrompt API that we’re providing in the AndroidX library. Android Q supports both standard and passive (no confirmation, for face and other passive modes) auth flows.

These are just a few of the many new features and APIs in Android Q -- to see them all, visit the Android Q Beta site for developers.

Publish your app updates to Google Play

Today with Android Q Beta 4 we’re also opening up publishing on Google Play to apps that are compiled against, or optionally targeting, API 29. This means you can now push your updates to users now through Google Play to test your app’s compatibility, including on devices running Android Q Beta 4.

How do I get Beta 4?

It’s easy! Just enroll any supported Pixel device here to get the update over-the-air. If you're already enrolled, you'll receive the update soon and no action is needed on your part. Downloadable system images are also available here. Partners that are participating in the Android Q Beta program will be updating their devices over the coming weeks. See android.com/beta for details.

For even broader testing on supported devices, you can also get Android GSI images, and if you don’t have a device you can test on the Android Emulator.

As always, your input is critical, so please continue to let us know what you think. You can use our hotlists for filing platform issues (including privacy and behavior changes), app compatibility issues, and third-party SDK issues. You've shared great feedback with us so far and we're working to integrate as much of it as possible in the next Beta release.

We're looking forward to seeing your apps on Android Q!

Indie Games Accelerator – Introducing class of 2019!

Posted by Vineet Tanwar, Business Development Manager, Google Play

In April we opened applications for the 2019 class of Indie Games Accelerator, a program to help top mobile game startups from emerging markets achieve their full potential on Google Play. We’re truly awed by the response we have received with over 1,700 applications from developers across 37 countries*. We continue to be impressed by the innovation and creativity of game developers everywhere.

Now, it's time to introduce you to the developers selected for the class of 2019. Here they are:

Congratulations to the selected participants and we look forward to meeting you in Singapore!

Find out more about the program or express your interest in joining the next class of the Indie Games Accelerator.

* The competition is open to developers from the following countries: Bangladesh, Brunei, Cambodia, India, Indonesia, Laos, Malaysia, Myanmar, Nepal, Pakistan, Philippines, Singapore, Sri Lanka, Thailand, Vietnam, Egypt, Jordan, Kenya, Lebanon, Nigeria, South Africa, Tunisia, Turkey, Argentina, Bolivia, Brazil, Chile, Colombia, Costa Rica, Ecuador, Guatemala, Mexico, Panama, Paraguay, Peru, Uruguay and Venezuela

How useful did you find this blog post?

Improved app quality and discovery on Google Play

Posted by Kosuke Suzuki, Product Manager, Google Play

Every month, more than 2 billion users from over 190 countries visit the Google Play Store to browse and discover new apps and games. As part of making Google Play a great discovery experience, we continue to increase our focus on quality. Over the coming weeks, we’ll be updating our featuring and ranking logic to further prioritize high quality apps and games with strong technical performance and engaging content.

If you’re looking for ways to improve your app quality, below are three key areas to focus on. Along with these suggestions, we've highlighted several tools available in the Google Play Console to help you better understand user behavior, monitor technical performance, and deliver the best in-app experience for users. Remember, app quality will impact where and how prominently you're eligible to surface in the store, so always look to create the most compelling and delightful experience possible.

Good in-app user experience

Have you thought about your UI and if your app has intuitive navigation, controls, and menu access? Do you have a good first-time-user experience, overall polished design, and enough content to keep users engaged for the long term?

Quality guidelines: meet user expectations and maximize your exposure opportunities by testing against the quality guidelines for different platforms.

Testing tracks: release early versions of your app to gather early user feedback and make improvements before full release.

Engaging content: build loyalty and sustainable app engagement by satisfying your users needs

Ad placement: for apps with ads integrated, ensure a good user experience by choosing the right ad format and placement throughout your app.

Strong app stability and technical performance

Have you considered whether your app has good overall technical performance, and if it is power-thrifty, responsive, efficient, and well-behaved? 42% of users who leave a 1-star review mention stability or bugs.

Android vitals: review the Android vitals dashboard to see how your app is performing on core vitals metrics including crash rate, ANR rate, excessive wakeups, and stuck partial wake locks in the background. Look at developer selected peer benchmarks to see how you measure up to others in your category. Exhibiting bad behavior in Android vitals will negatively affect the user experience in your app and could limit your exposure opportunities on Google Play.

Pre-launch reports: identify where your app has problems to ensure you’re presenting the highest possible quality to users upon launch. The pre-launch reports use automated tests on real devices that can identify layout issues, provide crash diagnostics, locate security vulnerabilities, and more.

Effective store listing page

Last but not least, a quality app also means having an effective and accurate listing page. Does your store listing page make a great first impression? Does it clearly and accurately communicate the value and intended use cases of your app?

Best practices: use strong creative assets, including your app title, icon, screenshots and video, along with a clear and informative app description, that provide an accurate representation of your app. To improve discovery opportunities, we suggest all pages have a video (set to public or unlisted and non-monetized) to inform users about your app, and for game developers to provide three or more 16:9 aspect ratio screenshots.

New icon specification: create a more polished experience on the store by updating your icon before June 24th.

Ratings and reviews: monitor your user ratings and reviews and respond to negative reviews where possible. When receiving a reply from developers, users increase their rating by +0.7 stars on average. Paying attention to ratings and reviews will be increasingly important as we rollout the new rating score in August 2019. This will place more weight on your most recent ratings in the Google Play Store.

Store listing experiments: A/B test different versions of your listing page amongst actual Google Play users. Make sure to test each component independently and run tests for at least a week in order to gather significant results.

Custom store listings: tailor your marketing messages to specific user groups based on their country, install state or even pre-registration. This is a great way to highlight key features and updates best suited for existing or lapsed users.

Localization: take advantage of Google Play’s worldwide reach to identify key markets, translate your app store listing, and even run store listing experiments to optimize for each country.

Get the most out of the Google Play Console and learn about improving app quality on the Academy for App Success, a free e-learning resource.

How useful did you find this blog post?

Google Play services and Firebase migrating to AndroidX

Posted by Doug Stevenson, Developer Advocate

Later this year, the Google Play services and Firebase SDKs will migrate from the Android Support libraries to androidx-packaged library artifacts. We are targeting this change for June/July of 2019. This will not only make our SDKs better, but make it easier for you to use the latest Jetpack features in your app.

If your app depends on any com.google.android.gms or com.google.firebase libraries, you should prepare for this migration. To quickly test your build with androidx-packaged library artifacts, add the following two lines to your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

If your build still works, then you're done! You will be ready to use the new Google Play services and Firebase SDKs when they arrive. If you experience any new build issues or want more information on this migration, visit the official Jetpack migration guide. We will communicate when the androidx migration is complete in the near future, stay tuned!

Building a safer Google Play for kids

Posted by Kanika Sachdeva, Product Manager, Google Play

At Google Play, we’re committed to providing a positive, safe environment for children and families. Over the last few years, we’ve helped parents find family-friendly content through the Designed for Families program and empowered them to set digital ground rules for their families with Family Link parental controls.

After taking input from users and developers we are evolving our Google Play policies to provide additional protections for children and families. These policy changes build on our existing efforts to ensure that apps for children have appropriate content, show suitable ads, and handle personally identifiable information correctly; they also reduce the chance that apps not intended for children could unintentionally attract them.

Over the next few months, we will continue to roll out additional features that will help parents make informed choices before they install apps for their kids.

What’s changing for developers

We are asking every developer to thoughtfully consider whether children are part of your target audience.

  • If children are part of your target audience, you must meet policy requirements in your app concerning content and handling of personally identifiable information.
  • Ads in your app that are served to children need to be appropriate and served from an ads network that has certified compliance with our families policies.
  • If children are not part of your target audience, you should make sure your app does not unintentionally appeal to them. We will double check your app marketing to confirm this and ask you to make adjustments where required.

Declaring a target audience

As part of the new policy, all developers must complete the new target audience and content section of the Google Play Console.

The new target audience and content section of the Google Play Console.

For most developers, the target audience does not include children and this section should be relatively quick to complete. If children are part of your target audience, we will ask you follow-up questions.

We will use the information you provide in the Google Play Console, along with our own review of your app marketing assets, to categorize your app and apply policies according to the following target audience groups: children, children and older users, older users.*

We recommend you review our new policies, developer guide, and this training before starting the target audience and content section so that you clearly understand the implications of your answers.

Rolling out these changes

These changes affect every developer on Play, so if your app is already live on the Google Play store, we want to give you time to make any necessary updates. Below are the key dates to keep in mind:

  • Today: Target audience and content section available in the Google Play Console. All new apps must comply with the updated policies.
  • September 1st, 2019: All existing apps must have filled out the new target audience and content section and complied with the updated policies.

Our commitment to you

We’re committed to providing the resources you need to understand and implement these changes. You can view more information on the Android developers website and access training on our new policies on Google Play's Academy for App Success. We have also increased our staffing and improved our communications for app review and appeals processes to help you get timely decisions and understand any changes that are needed.

Thanks in advance for the work you are putting in. We will continue to listen to your feedback and use it to improve the way we roll out these updates and communicate with the developer community.

*Note: The word “children” can mean different things in different locales and in different contexts. It is important that you determine what obligations and/or age-based restrictions may apply for the countries where you target your app.

How useful did you find this blog post?

Congratulations to the finalists of the Indie Games Showcase from Google Play

Posted by Patricia Correa, Director, Platforms & Ecosystems Developer Marketing

Google Play Indie Games Showcase Announcements gif

Back in March we opened submissions for the Indie Games Showcase, an international competition for games studios from Europe*, South Korea, and Japan who are constantly pushing the boundaries of storytelling, visual excellence, and creativity in mobile.

We were once again impressed by the diversity and creativity that the indie community is bringing to mobile, and we’re happy to announce the 20 finalists.

Check out the local websites to learn more about the finalists and the events.

European illustration with Eiffel Tower and Matryoshka dolls

Europe

Europe Finalists logos for Indie Games Showcase

AntVentor by LoopyMood (Ukraine)

CHUCHEL by Amanita Design (Czech Republic)

#DRIVE by Pixel Perfect Dude (Poland)

Fly THIS! By Northplay (Denmark)

Fobia by Tapteek (Russia)

G30 - A Memory Maze by Ivan Kovalov (Russia)

Gold Peaks by Afterburn (Poland)

Grayland by 1DER Entertainment (Slovakia)

Hexologic by MythicOwl (Poland)

Lucid Dream Adventure by Dali Games (Poland)

OCO by SPECTRUM48 (United Kingdom)

Ordia by Loju (United Kingdom)

Peep by Taw (Russia)

Photographs by EightyEight Games (United Kingdom)

Rest in Pieces by Itatake (Sweden)

Returner Zhero by Fantastic, yes (Denmark)

see/saw by Kamibox (Germany)

STAP by Overhead Game Studio (United Kingdom)

Tesla vs. Lovecraft by 10tons (Finland)

Tiny Room Stories: Town Mystery by Kiary games (Russia)

mt.Fuji and other Japanese emblems

Japan

Japan Finalists logos for Indie Games Showcase

ALTER EGO by 株式会社カラメルカラム

Infection - 感染 - by CanvasSoft

Jumpion - Make a two-step jump ! by Comgate

Lunch Time Fish by SoftFunk HULABREAKS

MeltLand by 個人

ReversEstory by 個人

キグルミキノコ Q-bit -第一章- by 個人

SumoRoll - Road to the Yokozuna by Studio Kingmo

Escape Game: The Little Prince by 株式会社 Jammsworks

Kamiori - カミオリ by TeamOrigami

Bear's Restaurant by 個人

クマムシさん惑星 ミクロの地球最強伝説 by Ars Edutainment

ゴリラ!ゴリラ!ゴリラ!by Gang Gorilla Games

Girl x Sun - Terasene - Tower defence & Novel game by SleepingMuseum

タシテケス by 個人

Destination: Dragons! by GAME GABURI

Cute cat's cake shop by 個人

Persephone by Momo-pi

Hamcorollin' by illuCalab.

Food Truck Pup: Cooking Chef by 合同会社ゲームスタート

Korean space needle and temple

South Korea

South Korea Finalists logos for Indie Games Showcase

다크타운 - 온라인 by 초콜릿소프트

Bad 2 Bad: Extinction by Dawinstone

셧더펑 : 슈팅액션 by Take Five Games

Cartoon Craft by Studio NAP

Catch Idle by HalftimeStudio

Hexagon Dungeon by Bleor Games

Hexonia by Togglegear

Mahjong - Magic Fantasy by Aquagamez

Maze Cube by IAMABOY

Road to Valor: World War II by Dreamotion Inc.

Onslot Car by Wondersquad

ROOMS: The Toymaker's Mansion by HandMade Game

Rhythm Star: Music Adventure by Anbsoft

7Days - Decide your story by Buff Studio

Seoul2033: Backer by Banjiha Games

Super Jelly Pop by STARMONSTER

UNLINK Daily Puzzle by Supershock

몬스터파크 온라인 by OVENCODE

WhamBam Warriors by DrukHigh

언노운 나이츠 by teamarex

We will welcome all finalists at events in London, Seoul, and Tokyo, where they will showcase their games to an audience of players, press and industry experts, for a chance to win the top prizes.

The events are open to the public, so if you would like to meet these games developers, try out their creations, and help choose the winners, sign up on the regional websites.

Congratulations to all finalists!

* The competition is open to developers from the following European countries and Israel: Austria, Belgium, Belarus, Czech Republic, Denmark, Finland, France, Germany, Italy, Netherlands, Norway, Poland, Romania, Russia, Slovakia, Spain, Sweden, Ukraine, and the United Kingdom (including Northern Ireland).

How useful did you find this blog post?

Wide Color Photos Are Coming to Android: Things You Need to Know to be Prepared

Posted by Peiyong Lin, Software Engineer

Android is now at the point where sRGB color gamut with 8 bits per color channel is not enough to take advantage of the display and camera technology. At Android we have been working to make wide color photography happen end-to-end, e.g. more bits and bigger gamuts. This means, eventually users will be able to capture the richness of the scenes, share a wide color pictures with friends and view wide color pictures on their phones. And now with Android Q, it's starting to get really close to reality: wide color photography is coming to Android. So, it's very important to applications to be wide color gamut ready. This article will show how you can test your application to see whether it's wide color gamut ready and wide color gamut capable, and the steps you need to take to be ready for wide color gamut photography.

But before we dive in, why wide color photography? Display panels and camera sensors on mobile are getting better and better every year. More and more newly released phones will be shipped with calibrated display panels, some are wide color gamut capable. Modern camera sensors are capable of capturing scenes with a wider range of color outside of sRGB and thus produce wide color gamut pictures. And when these two come together, it creates an end-to-end photography experience with more vibrant colors of the real world.

At a technical level, this means there will be pictures coming to your application with an ICC profile that is not sRGB but some other wider color gamut: Display P3, Adobe RGB, etc. For consumers, this means their photos will look more realistic.

orange sunset

Display P3

orange sunset

SRGB

Colorful umbrellas

Display P3

Colorful umbrellas

SRGB

Above are images of the Display P3 version and the SRGB version respectively of the same scene. If you are reading this article on a calibrated and wide color gamut capable display, you can notice the significant difference between these them.

Color Tests

There are two kinds of tests you can perform to know whether your application is prepared or not. One is what we call color correctness tests, the other is wide color tests.

Color Correctness test: Is your application wide color gamut ready?

A wide color gamut ready application implies the application manages color proactively. This means when given images, the application always checks the color space and does conversion based on its capability of showing wide color gamut, and thus even if the application can't handle wide color gamut it can still show the sRGB color gamut of the image correctly without color distortion.

Below is a color correct example of an image with Display P3 ICC profile.

large round balloons outside on floor in front of a concrete wall

However, if your application is not color correct, then typically your application will end up manipulating/displaying the image without converting the color space correctly, resulting in color distortion. For example you may get the below image, where the color is washed-out and everything looks distorted.

large round balloons outside on floor in front of a concrete wall

Wide Color test: Is your application wide color gamut capable?

A wide color gamut capable application implies when given wide color gamut images, it can show the colors outside of sRGB color space. Here's an image you can use to test whether your application is wide color gamut capable or not, if it is, then a red Android logo will show up. Note that you must run this test on a wide color gamut capable device, for example a Pixel 3 or Samsung Galaxy S10.

red Android droid figure

What you should do to prepare

To prepare for wide color gamut photography, your application must at least pass the wide color gamut ready test, we call it color correctness test. If your application passes the wide color gamut ready tests, that's awesome! But if it doesn't, here are the steps to make it wide color gamut ready.

The key thing to be prepared and future proof is that your application should never assume sRGB color space of the external images it gets. This means application must check the color space of the decoded images, and do the conversion when necessary. Failure to do so will result in color distortion and color profile being discarded somewhere in your pipeline.

Mandatory: Be Color Correct

You must be at least color correct. If your application doesn't adopt wide color gamut, you are very likely to just want to decode every image to sRGB color space. You can do that by either using BitmapFactory or ImageDecoder.

Using BitmapFactory

In API 26, we added inPreferredColorSpace in BitmapFactory.Option, which allows you to specify the target color space you want the decoded bitmap to have. Let's say you want to decode a file, then below is the snippet you are very likely to use in order to manage the color:

final BitmapFactory.Options options = new BitmapFactory.Options();
// Decode this file to sRGB color space.
options.inPreferredColorSpace = ColorSpace.get(Named.SRGB);
Bitmap bitmap = BitmapFactory.decodeFile(FILE_PATH, options);

Using ImageDecoder

In Android P (API level 28), we introduced ImageDecoder, a modernized approach for decoding images. If you upgrade your apk to API level 28 or beyond, we recommend you to use it instead of the BitmapFactory and BitmapFactory.Option APIs.

Below is a snippet to decode the image to an sRGB bitmap using ImageDecoder#decodeBitmap API.

ImageDecoder.Source source =
        ImageDecoder.createSource(FILE_PATH);
try {
    bitmap = ImageDecoder.decodeBitmap(source,
            new ImageDecoder.OnHeaderDecodedListener() {
                @Override
                public void onHeaderDecoded(ImageDecoder decoder,
                        ImageDecoder.ImageInfo info,
                        ImageDecoder.Source source) {
                    decoder.setTargetColorSpace(ColorSpace.get(Named.SRGB));
                }
            });
} catch (IOException e) {
    // handle exception.
}

ImageDecoder also has the advantage to let you know the encoded color space of the bitmap before you get the final bitmap by passing an ImageDecoder.OnHeaderDecodedListener and checking ImageDecoder.ImageInfo#getColorSpace(). And thus, depending on how your applications handle color spaces, you can check the encoded color space of the contents and set the target color space differently.

ImageDecoder.Source source =
        ImageDecoder.createSource(FILE_PATH);
try {
    bitmap = ImageDecoder.decodeBitmap(source,
            new ImageDecoder.OnHeaderDecodedListener() {
                @Override
                public void onHeaderDecoded(ImageDecoder decoder,
                        ImageDecoder.ImageInfo info,
                        ImageDecoder.Source source) {
                    ColorSpace cs = info.getColorSpace();
                    // Do something...
                }
            });
} catch (IOException e) {
    // handle exception.
}

For more detailed usage you can check out the ImageDecoder APIs here.

Known bad practices

Some typical bad practices include but are not limited to:

  • Always assume sRGB color space
  • Upload image as texture without necessary conversion
  • Ignore the ICC profile during compression

All these cause a severe users perceived results: Color distortion. For example, below is a code snippet that results in the application not color correct:

// This is bad, don't do it!
final BitmapFactory.Options options = new BitmapFactory.Options();
final Bitmap bitmap = BitmapFactory.decodeFile(FILE_PATH, options);
glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES31.GL_RGBA, bitmap.getWidth(),
        bitmap.getHeight(), 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, bitmap,
        GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE);

There's no color space checking before uploading the bitmap as the texture, and thus the application will end up with the below distorted image from the color correctness test.

large round balloons outside on floor in front of a concrete wall

Optional: Be wide color capable

Besides the above changes you must make in order to handle images correctly, if your applications are heavily image based, you will want to take additional steps to display these images in the full vibrant range by enabling the wide gamut mode in your manifest or creating a Display P3 surfaces.

To enable the wide color gamut in your activity, set the colorMode attribute to wideColorGamut in your AndroidManifest.xml file. You need to do this for each activity for which you want to enable wide color mode.

android:colorMode="wideColorGamut"

You can also set the color mode programmatically in your activity by calling the setColorMode(int) method and passing in COLOR_MODE_WIDE_COLOR_GAMUT.

To render wide color gamut contents, besides the wide color contents, you will also need to create a wide color gamut surfaces to render to. In OpenGL for example, your application must first check the following extensions:

And then, request the Display P3 as the color space when creating your surfaces, as shown in the following code snippet:

private static final int EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT = 0x3490;

public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
  EGLSurface surface = null;
  try {
    int attribs[] = {
      EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT,
      egl.EGL_NONE
    };
    surface = egl.eglCreateWindowSurface(display, config, nativeWindow, attribs);
  } catch (IllegalArgumentException e) {}
  return surface;
}

Also check out our post about more details on how you can adopt wide color gamut in native code.

APIs design guideline for image library

Finally, if you own or maintain an image decoding/encoding library, you will need to at least pass the color correctness tests as well. To modernize your library, there are two things we strongly recommend you to do when you extend APIs to manage color:

  1. Strongly recommend to explicitly accept ColorSpace as a parameter when you design new APIs or extend existing APIs. Instead of hardcoding a color space, an explicit ColorSpace parameter is a more future-proof way moving forward.
  2. Strongly recommend all legacy APIs to explicitly decode the bitmap to sRGB color space. Historically there's no color management, and thus Android has been treating everything as sRGB implicitly until Android 8.0 (API level 26). This allows you to help your users maintain backward compatibility.

After you finish, go back to the above section and perform the two color tests.

Kotlin Is Everywhere! Join the global event series

Posted by Posted by Florina Muntenescu & Wojtek Kaliciński, Developer Advocates, Android

Last week at Google I/O, we announced a big step: Android development will become increasingly Kotlin-first. It’s a language that many of you already love: over 50% of professional Android developers now use Kotlin, and it’s the fastest-growing language on GitHub. As part of this announcement, many new Jetpack APIs and features will be offered first in Kotlin. So if you’re starting a new project, you should try writing it in Kotlin; code written in Kotlin often means much less code for you–less code to type, test, and maintain.

To help you dive deeper into Kotlin, we’re happy to announce a new program we’re launching together with JetBrains: Kotlin/Everywhere, a series of community-driven events focussing on the potential of Kotlin on all platforms. We are aiming to help learn the essentials and best practices of using Kotlin everywhere, be it for Android, back-end, front-end and other platforms.

Join the Kotlin/Everywhere global event series between June and December 2019.

Who can attend the events?

Whether you are a developer, a speaker, a Kotlin User Group, a Google Developer Group member or any other community leader join us. Anyone interested in learning Kotlin and its ecosystem, sharing knowledge, and hosting a Kotlin-focused event is welcome to attend.

If you are a developer wanting to learn more about Kotlin, or a speaker excited to share your Kotlin experience with others, you can find events near you to join. Just go to the map on the website. More events will be added over time.

How to host your Kotlin/Everywhere event?

If you want to host an event in your city, you can begin by checking out the detailed organizers’ guide. It will help you to decide on the format and what kind of support you might need. All the necessary tips and tricks, materials, and branding assets are inside. Go ahead and submit your event on the official web page.

Besides the detailed organizers’ guide, we also provide you with resources such as content, codelabs, and guidance to help you maximize your success. You can also apply for support: we have speakers from Google/JetBrains and can help by providing funding for venue, food and drinks, swag, or other. We will also list your event on the official website.

Still have questions? Ask them at our hangout sessions for organizers on May 16 and 17.

Let us know if you want to take part! Apply at kotl.in/everywhere

New! Learn How to Build Android Apps with Android Jetpack and Kotlin

Posted by Dan Galpin

Developing Android Apps with Kotlin, developed by Google together with Udacity, is our newly-released, free, self-paced online course. You'll learn how to build Android apps using industry-standard tools and libraries in the Kotlin programming language.

Android development fundamentals are taught in the context of an architecture that provides the scaffolding for robust, maintainable applications. The course covers why and how to use Android Jetpack components such as Room for databases, Work Manager for background processing, the Navigation component, and more. You'll use popular community libraries to simplify common tasks such as Glide for image loading, Retrofit for networking, and Moshi for JSON parsing. The course teaches key Kotlin features such as coroutines to help you write your app code more quickly and concisely.

As you work through the course, you'll build fun and interesting apps, such as a Mars photo gallery, a trivia game, a sleep tracker and much more.

Two mobile phones with flow chart in between depicting the difference between an over view and details.
Three screens for Android Navigation Component Trivia screen on mobile

This course is intended for people who have programming experience and are comfortable with Kotlin basics. If you're new to the Kotlin language, we recommend taking the Udacity Kotlin Bootcamp course first.

The course is available free, online at Udacity; take it in your own time at your own pace.

Come learn how to build Android apps in Kotlin with us at https://www.udacity.com/course/ud9012.