Tag Archives: Develop

Meet 5 Android developers working to improve lives around the world

Posted by Maxim Mai, Apps Partnerships, Google Play

Last Thursday at Google I/O 2017, we announced the winners of this year's Google Play Awards. Grab some popcorn and watch the award ceremony, we think it's just as fun as The Oscars. This year, we included a category to celebrate the achievements of developers who publish outstanding apps that have positive social impact.

In introducing this awards category, we were inspired by the UN's 17 Sustainable Development Goals. With the ability to reach over 1 billion active Android devices around the world, we think that app developers have a tremendous opportunity to impact Zero Hunger (SDG #2), Good Health and Wellbeing (SDG #3) and Quality Education (SDG #4), and many others. Read on to find out more about how this year's winner and finalists and impacting these goals.

Get in touch about your social impact app or game

Our work in supporting developer success in this area on Android and Google Play is just beginning. We would like to encourage Android developers with a focus on social impact to get in touch with us here at Google Play and to tell us about their app or game. It doesn't matter where you are based, what problems you are solving, or which countries you are targeting, we would like to hear your story and maybe we can help you grow faster and improve your app's quality.

Social impact winner & finalists in the 2017 Google Play Awards

? ShareTheMeal by United Nations ?

The Google Play Award category winner, ShareTheMeal, generates large scale, global awareness for "Zero Hunger" and its users' donations pay for school meals, which are provided by the World Food Programme, in regions around the world experiencing food insecurity. Over 13 million meals have been donated via the app since launch!

Charity Miles by Charity Miles

This is a running, cycling and walking tracker app with a social impact twist. Charity Miles earns money for charity on your behalf for every mile you move, via its brand fitness exercise sponsors! Users have already donated $2 million to charity by recording over 40 million miles!

Peek Acuity by Peak Vision

Peek Acuity allows anyone with an Android phone to easily measure visual acuity, which is one of the components of vision. It is designed by eye care professionals to be used to help identify people who need further examination by, for example, an optometrist or ophthalmologist. In developing countries, over XM [confirm number with Peek Vision] struggle with vision impairment and many don't have easy access to an eye care professional.

Prodeaf Translator by ProDeaf Tecnologias Assistivas

This app lets anyone translate phrases and words from Portuguese for Brazilian Sign Language (Libras) or from English to American Sign Language (ASL). This significantly reduces barriers to communication between the millions of people who depend on Libras or ASL as their lingua franca and others who have not had the opportunity to learn this form of communication.

Sea Hero Quest by GLITCHERS

This is not just a game, it's a quest to help scientists fight dementia! It sounds too good to be true but this really is a game, where simply by having loads of fun chasing creatures around magical seas and swamps, you can help to fight a disease that currently affects 45 million people worldwide. In fact playing SEA HERO QUEST for just 2 minutes will generate the equivalent of 5 hours of lab-based research data.

If you're working on an app or game with a positive social impact, don't forget to get in touch via this form and tick the "Social Impact app" checkbox.

How useful did you find this blogpost?

Android Announces Support for Kotlin

By Mike Cleron, Director, Android Platform
Today the Android team is excited to announce that we are officially adding support for the Kotlin programming language. Kotlin is a brilliantly designed, mature language that we believe will make Android development faster and more fun. It has already been adopted by several major developers — Expedia, Flipboard, Pinterest, Square, and others — for their production apps. Kotlin also plays well with the Java programming language; the effortless interoperation between the two languages has been a large part of Kotlin's appeal.
The Kotlin plug-in is now bundled with Android Studio 3.0 and is available for immediate download. Kotlin was developed by JetBrains, the same people who created IntelliJ, so it is not surprising that the IDE support for Kotlin is outstanding.
In addition to the IDE support, we're announcing a collaboration with JetBrains to move Kotlin into a non-profit foundation. (Kotlin is already open sourced under Apache2.)

Say "Hello" to Kotlin

Kotlin will be very familiar to anyone who has used the Java programming language.
package helloWorld

fun main(args: Array) {
   println("Hello World!")
}
At first glance, you will see comforting elements like curly braces, classes, packages, functions and methods. But as you go deeper, you will discover that although Kotlin is based on familiar concepts, it is a uniquely modern, elegant and pragmatic riff on those models. In particular, Kotlin is highly expressive with minimal syntactic friction between your thoughts and what you have to type in order to express those thoughts. If when writing code you have asked yourself questions that began "why do I have to …?" you will be pleased to learn that in Kotlin the answer to many of those questions is "you don't!"
For example, perhaps you have asked why you need to type in a bunch of boilerplate getters and setters as well as overriding equals(), hashCode() and toString() when implementing a simple class. Here is a typical example from the Java programming language (in a microscopic font for brevity).
public class Customer {
   private String name;
   private String email;
   private String company;

   public Customer(String name) {
       this(name, "", "");
   }

   public Customer(String name, String email) {
       this(name, email, "");

   }

   public Customer(String name, String email, String company) {
       this.name = name;
       this.email = email;
       this.company = company;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public String getEmail() {
       return email;
   }

   public void setEmail(String email) {
       this.email = email;
   }

   public String getCompany() {
       return company;
   }

   public void setCompany(String company) {
       this.company = company;
   }

   @Override
   public boolean equals(Object o) {
       if (this == o) return true;
       if (o == null || getClass() != o.getClass()) return false;

       Customer customer = (Customer) o;

       if (name != null ? !name.equals(customer.name) : customer.name != null) return false;
       if (email != null ? !email.equals(customer.email) : customer.email != null) return false;
       return company != null ? company.equals(customer.company) : customer.company == null;
   }

   @Override
   public int hashCode() {
       int result = name != null ? name.hashCode() : 0;
       result = 31 * result + (email != null ? email.hashCode() : 0);
       result = 31 * result + (company != null ? company.hashCode() : 0);
       return result;
   }

   @Override
   public String toString() {
       return "Customer{" +
               "name='" + name + '\'' +
               ", email='" + email + '\'' +
               ", company='" + company + '\'' +
               '}';
   }
}
In Kotlin, you don't have to type any of that. This single line is equivalent to the entire class above.
data class Customer(var name: String, var email: String = "",
                    var company: String = "")

History and Reference

Kotlin has been around for quite a while; it was announced back in 2011 and the first preview was released in 2012. Kotlin 1.0 was released in 2016, at which point JetBrains committed to maintaining backwards compatibility for stable features from 1.0 forward.
You can find excellent training material and references at https://kotlinlang.org/. The Android team has found the Kotlin Koans tutorial to be especially helpful as a quick way to get started writing some Kotlin snippets. These tutorials range from the simple to the sublime as the material progresses from the basics to more sophisticated Kotlin idioms.

Why Kotlin?

Why did the Android team decide to support Kotlin? Most importantly, it was because we think Kotlin is a great language that will make writing Android apps easier and more enjoyable.
Kotlin is also a great match for the existing Android ecosystem. It is 100% compatible with the Java programming language. You can add as little or as much Kotlin into your existing codebase as you want and mix the two languages freely within the same project. Calling out to Kotlin code from code written in the Java programming language Just Works™. Going the other direction usually works without any developer effort too via some automatically applied translation conventions (for example, things like property getters and setters are created for you). With the help of a few Kotlin annotations, you can also customize how the translation is performed.
Finally, many, many developers have told us they love the Kotlin language. (Many of our own developers on the Android team have also been saying similar things.) There is already an enthusiastic community of Kotlin developers for Android, and the Android team has been routinely peppered with questions about Kotlin at public events. The Android community has spoken, and we listened.

A Quick Tour

To help you get a sense of where all of the excitement around Kotlin is coming from, here is a quick, very-much-not-comprehensive tour of some of the particularly appealing aspects of Kotlin:
Nullable
The Kotlin compiler enforces that variables that can hold null values are explicitly declared – thus no more NullPointerExceptions at runtime!
var neverNull: String = "something"
var mightBeNull: String? = null // "?" indicates this can be null

if (neverNull.length > 0) {   // This is OK
    …
}

if (mightBeNull.length > 0) { // Compiler catches this error for you
    …
}
Named parameters and default arguments
We've all seen methods that have too many parameters to keep track of. For example:
fun orderPizza(size: Size, pepperoni: Boolean, mushrooms: Boolean,
               ham: Boolean, pineapple: Boolean, pickles: Boolean,
               sausage: Boolean, peppers: Boolean, onion: Boolean)
{
    ...
}

// Wait… did I just order pickles on my pizza?
// Why do we even have that option?
orderPizza(Size.LARGE, true, false, false, false, true,
           false, true, false)
Compare that to a similar scenario using named parameters and default arguments:
fun orderPizza(size: Size,
               pepperoni: Boolean = false,
               mushrooms: Boolean = false,
               ham: Boolean = false,
               pineapple: Boolean = false,
               pickles: Boolean = false,
               sausage: Boolean = false,
               peppers: Boolean = false,
               onion: Boolean = false)
{
    ...
}

orderPizza(Size.LARGE, ham = true, mushrooms = true)
In addition to helping to avoid tragic pizza outcomes, this is much easier to read. It also reduces the number of variants of overloaded functions you need to write.
When statement
Kotlin has a variation of a switch statement that allows matching on arbitrary expressions.
// Please don't put this in your app!
when {
    password.equals("password") -> println("Insecure password!")
    password.length < 4 -> println("Too short!")
    else -> {
        println("Secure password!")
    }
}
Smart Casts
Why should you have to cast something to a class right after you just tested that it is an instance of that class? In Kotlin, you don't have to do that anymore.
if (obj is String) {
    // Compiler casts obj to a String for you.
    // (Would work with && instead of nested ifs too.)
    if (obj.length > 0) {
        …
    }
}
This generalizes to the when statement as well:
// Assume reasonable implementations of Cat and Dog
when (obj) {
   is Cat -> obj.meow(...)
   is Dog -> obj.woof(...)
   else -> {
        …
   }
}
Extension functions
Kotlin lets you essentially retcon new methods onto an existing type. If you, like many people, wish that the String class had a toPigLatin method, you can now add it yourself without having to create a new helper class to wrap String or going through the trouble of serving on a language committee:
// The "String." prefix indicates that this method should
// extend the existing String class
fun String.toPigLatin() : String {
    ...
}

val plainOldString : String = "some text"

// Can now call toPigLatin as if were a method on String
println(plainOldString.toPigLatin())

// Or:
println("some text".toPigLatin())
Destructuring Declarations
We have already seen how easy it is to define a simple data class:
data class Order(val itemCode: String, val quantity: Int,
                 val price: Float)
A function that uses one of these classes as the return type is very close to supporting multiple return values:
fun getOrder(...): Order {
    ...
    return Order(itemCode, quantity, price);
}
To get all the way there, you can use the destructuring declaration syntax. The following statement takes the Order object, extracts its three properties, and then assigns them to the three variables what, howMany and howMuch — all courtesy of the Kotlin compiler, which also infers the correct types for you.
val (what, howMany, howMuch) = getOrder(...)
Lambdas
Kotin has an extremely concise syntax for lambdas that makes is easy to express powerful functional programming paradigms. Here's a simple example that uses a lambda to test that everything in a collection is a String:
fun allStrings(collection: Collection)=
    collection.all { it is String }
That lambda syntax is building block of one of Kotlin's coolest features: the ability to create builders that use JSON-like syntax that also happens to be syntactically valid Kotlin. This example is adapted from an extended discussion here, but you can get the flavor of what it possible with this snippet:
fun generatePage(withEmphasis : Boolean) {
    val result =
        html {
            head {
                title { +"Kotlin Builders" }
            }
            body {
                h1 { +"Kotlin Builders" }
                p {
                    +"This is "
                    if (withEmphasis) b { +"really " }
                    +"interesting"
                    a(href = "https://goo.gl/rHwJio") { +"More here" }
                }
            }
        }
    println(result)
}
There are a couple of interesting things going on here. First, this shows how expressive Kotlin's functional syntax can be: in this example, "html", "head", "body, etc. are all just functions written in Kotlin and the stuff in curly braces that follows are functional parameters. (This snippet uses functions with names that match HTML tags to build a representation of a web page, but of course you can use this pattern to build any complex data structure with whatever names you want.) The second interesting thing is the "withEmphasis" conditional. This may look like we are mixing code (if (withEmphasis) …) with data (all the HTML-esque tags), but the "data" here is actually just more code. Since it is all really just code, this lets you build complex data structures using a declarative syntax while also having inline access to the full capabilities of the Kotlin language.

Getting Started

If you want to get started with Kotlin, you can start playing with code online immediately here. Just hit the green triangle to compile and run.
To try Kotlin in your app, follow these steps:
  1. Download Android Studio 3.0
  2. Open one of your existing ".java" files
  3. Invoke "Code > Convert Java File to Kotlin File"
The IDE will then walk you through adding Kotlin dependencies into your project, and then convert the code to functionally equivalent Kotlin code. (The IDE will also offer to touch up all of the call sites to the converted class when suitable to be more idiomatic Kotlin such as when static methods are moved to companion objects.)
You can also find a lot more information on how to start using Kotlin on developer.android.com.

Android Instant Apps is open to all developers. Start building today!

Posted by: Jonathan Karmel, Product Manager

Earlier this year, we began testing Android Instant Apps, a new way to run Android apps without requiring installation. Thanks to our incredible developer community, we received a ton of feedback that has helped us refine the end-to-end product experience.

Today, we're opening Android Instant Apps to all developers, so anyone can build and publish an instant app. There are also more than 50 new experiences available for users to try from a variety of developers, such as HotPads, Jet, the New York Times, Vimeo, and One Football. While these experiences have only been live for a short amount of time, the early data shows positive results. For example, Jet and HotPads are seeing double digit increases in purchases and leads generated.

(left to right: One Football, Dotloop, Jet, Vimeo, HotPads and The New York Times)

Feedback from our early partners has directly shaped the development tools we're making available to all of you today.

To get started building an instant app, head over to developer.android.com and download the latest preview of Android Studio 3.0 and the Android Instant Apps SDK. You'll continue to use a single codebase. Android Studio provides the tools you need to modularize your app so that features can be downloaded as needed. Every app is different, but we've seen with our early partners that with the latest tools, instant app development typically takes about 4-6 weeks.

Once you've built your app, the Play Console provides support for distributing your instant app. You just upload your instant app APKs together with your installable APK.

Instant Apps continues to ramp up on the latest Android devices in more than 40 countries. And with Android O, we've gone further, building a new, more efficient runtime sandbox for instant apps, sharable support libraries to reduce app size, and launcher integration support.

To learn more, visit g.co/InstantApps. We're also hosting a session "Introduction to Android Instant Apps" on Thursday, May 18 from 1:30-2:30 PM PT at the conference to dig deeper into the topic. You'll also be able to watch the live stream on Google I/O YouTube channel.

We are excited to see what experiences you create with Instant Apps!

Android Studio 3.0 Canary 1




By Jamal Eason, Product Manager, Android

Just in time for Google I/O 2017, we're providing a sneak peak of Android Studio 3.0 - available to download today on our canary release channel. Android Studio's our official IDE, purpose-built for Android, and we keep increasing our investment. The feature set in Android Studio is focused on accelerating your app development flow and providing the latest tools built for the Android platform.

To accelerate your development flow, Android Studio 3.0 includes three major features: a new suite of app performance profiling tools to quickly diagnose performance issues, support for the Kotlin programming language, and increased Gradle build speeds for large sized app projects. Android Studio 3.0 also tightly integrates with Android platform development with these additional key features: support for Instant App development, inclusion of the Google Play Store in the Android O emulator system images, and new wizards for Android O development. Overall, this first canary release of Android Studio 3.0 has 20+ new features.

We have been quietly iterating on many of these features as part of the Android Studio 2.4 Canaries. Today we are renumbering the release to Android Studio 3.0 after recognizing that we added many significant features, and that we had to introduce a rare breaking change in the Android Gradle Plugin to improve scalability and build times. If you want to target Android O, create an Instant App, start developing with the Kotlin language or use the latest in Android app performance tools to improve your app quality then you should download Android Studio 3.0 Canary 1 today.
Android DevByte - What’s New in Android Studio 3.0 Canary 1


Check out the the list below organized into key developer flow for the details of the new features in this first canary release of Android Studio 3.0.

Develop


  • Kotlin Programming Language - By popular request, Android Studio 3.0 now includes support for Kotlin. With this new language support, you can seamlessly add Kotlin code next to your existing Android app code and have access to all the great development tools found in Android Studio. You can choose to add Kotlin to your project using the built-in conversion tool found under CodeConvert Java File to Kotlin File, or you choose to create a Kotlin enabled project with the New Project Wizard. Lean more about Kotlin language support in Android and Android Studio.

Kotlin Language Conversion in Android Studio


  • Java 8 Language features - We are continuing to evolve the support for Java 8 language features and APIs. With the recent deprecation of the Jack toolchain and migration to the javac based toolchain, you have access to features such as Instant Run for projects using the Java 8 language features in Android Studio. To update your project to support the new Java 8 Language toolchain, simply update your Source and Target compatibility levels to 1.8 in the Project Structure dialog. Learn more.
Update Project Structure Dialogue for Java 8 Language




  • Layout Editor - With this Android Studio release, you will find additional enhancements to the Layout Editor. We have updated the component tree with better drag-and-drop view insertions, and a new error panel. In coordination with an update to ConstraintLayout, the Layout Editor also supports creating view Barriers, creating Groups, and enhances Chain Creation. Learn more.
Layout Editor Component Tree & Warning Panel



  • Adaptive Icon Wizard - Android O introduces adaptive launcher icons, which can display in different shapes across different Android devices. The new Adaptive Launcher Icon wizard creates the new and legacy launcher icon assets and provides previews of how your adaptive icon will look on different launcher screen icon masks. Create a new asset by right-clicking on the /res folder in your project then navigate to → NewImage AssetLauncher Icons (Adaptive and Legacy) Learn more.
Adaptive Icon Wizard



  • XML Fonts & Downloadable Fonts - Adding custom fonts to your app (available when targeting Android O) is now even easier with the XML fonts preview and font selection tools in Android Studio. You can can also create a downloadable font resource for your app. Using downloadable fonts allows you to use a custom font in your app while avoiding the need to bundle in a font resource into your APK. To use downloadable fonts, ensure that you device or emulator is running Google Play Services v11.2.63 or higher. Learn more.
Downloadable Fonts Resource Picker

XML Fonts Preview




  • Android Things Support - With Android Studio 3.0, you can start developing on Android Things with a new set of templates in the New Project wizard and the New Module wizard. Android Things allows you to extend your Android development knowledge into the Internet of Things (IoT) device category. Learn more.

Android Things New Module Wizard 




  • IntelliJ Platform Update: Android Studio 3.0 Canary 1 includes the IntelliJ 2017.1 release, which has features such as Java 8 language refactoring, parameter hints, semantic highlighting, draggable breakpoints, enhanced version control search, and more. Learn more.

Build

  • Instant App Support - With Android Studio 3.0, you can create Instant Apps in your project. Instant Apps are lightweight Android apps that your users can immediately run without installation. To support this, Android Studio introduces two new module types: instant app and feature. Combined with a new "Modularize" refactoring action and the App Links Assistant, Android Studio can help you extend your app into an Instant App. To use you can use the New Module Wizard or right-click on a class and navigate to: RefactorModularize Learn more.

Instant App Module Wizard



  • Build Speed Improvements - We are continuing to invest in making build speeds faster. For this release, we focused on improving speed for projects that have many modules. To achieve these speed improvements and to support future enhancements, we have made breaking API changes to the Android Gradle plugin used by Android Studio. If you depended on APIs provided by the previous plugin you should validate compatibility with the new plugin and migrate applicable APIs. To test, update the plugin version in your build.gradle file. Learn more.



build.gradle

dependencies {
   classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
}
  • Google's Maven Repository - Also, by popular request, we are now distributing the Android Support Library maven dependencies outside of the Android SDK Manager in a brand new Maven repository. For those developing with a Continuous Integration (CI) system, this should make Maven dependency management easier. Used in combination with the latest command line SDK Manager tool and Gradle, CI builds should be easier to manage with Google's Maven Repository. To use the the new Maven location, add the following url to your app module's build.gradle file. Learn more.
build.gradle
repositories {
   maven {
       url "https://maven.google.com"
   }
}



    Test & Debug

    • Google Play System Images - Along with the update to the Android O Beta release, we updated the Android Emulator O system images to include the Google Play Store. Bundling in the Google Play store allows you to do end-to-end testing of apps with Google Play, and provides a convenient way to keep Google Play services up-to-date in your Android Virtual Device (AVD). Just as Google Play services updates on physical devices, you can trigger the same updates on your AVDs.
    Google Play Store in Android Emulator



    Update Google Play Services in Android Emulator




    To ensure app security and a consistent experience with physical devices, the emulator system images with the Google Play store included are signed with a release key. This means you will not be able to get elevated privileges. If you require elevated privileges (root) to aid with your app troubleshooting, you can use the Android Open Source Project (AOSP) emulator system images that do not include Google apps or services. To get started, make sure you are using Android Emulator v26.1+, the latest system images API 24+ and then create a new AVD with a Google Play icon next to the device definition. Learn more.


    Android Virtual Device Manager with Google Play Store Support 





    • OpenGL ES 3.0 Support in Android Emulator - As a part of our ongoing investment in making your development experience fast, the latest version of the Android Emulator has OpenGL ES 3.0 support for Android O system images along with significant improvements in OpenGL ES 2.0 graphics performance for older emulator system images. Most modern graphics cards on all operating systems support OpenGL ES 2.0 acceleration. To use OpenGL ES 3.0 with the Android Emulator, your development machine needs a host GPU graphics card that supports OpenGL 3.2 or higher on Microsoft® Windows® or Linux (with Apple MacOS® support coming in the future). Learn more.


    OpenGL ES 3.0 in Android Emulator




    • App Bug Reporter in Android Emulator - To help in documenting bugs in your app, we have added an easier way to generate a bug report with all the necessary configuration settings and space to capture your repro steps. Additionally, if you want to share a specific emulator bug with the Android team, we have also added a link to quickly generate a bug on the Android Issue Tracker. To use this feature, navigate to the Emulator Tool BarExtended ControlsHelpEmulator HelpFile a Bug. Learn more.

    App Bug Reporting in Android Emulator


    • Proxy Support in Android - For those who need to use a HTTP proxy to access the Internet, we have added a user interface to manage the proxy settings used by the emulator. By default, the Android Emulator will now use the settings from Android Studio, but you can override these settings for your network setup. To configure navigation to the Extended ControlsSettingsProxy.
    Android Emulator Proxy Settings


    • Android Wear Rotary Controls in Android Emulator - The Android Emulator now supports rotary controls for the Android Wear 2.0 emulator system image. It is now easier to test your apps that target Android Wear devices that include rotary input scrolling. To enable, create an Emulator AVD that targets Android Wear, and the Rotary Input panel should appear under Extended controls. Learn more.

    Rotary input in Android Emulator



    • APK Debugging - For those of you who just want to debug an APK without building your project in Android Studio, the Android Studio 3.0 release now has the ability to debug an arbitrary APK. This functionally is especially helpful for those who develop your Android C++ code in another development environment, but want to debug and analyze the APK in the context of Android Studio. As long as you have a debuggable version of your APK, you can use the new APK Debugging features to analyze, profile & debug the APK. Moreover, if you have access to the sources of your APK, you can link the source to the APK debugging flow for a higher fidelity debugging process. Get started by simply selecting Profile or debug APK from the Android Studio Welcome Screen or File → Profile or debug APKLearn More.

    Profile or Debug an APK


    APK Debugging


    • Layout Inspector - You will find that the Layout Inspector has a few additional enhancements in Android Studio 3.0 that make it easier to debug issues in your app layouts. A couple of the enhancements include better grouping of properties into common categories, as well as search functionality in both the View Tree and Properties Panels. While an application is running, access the Layout Inspector via ToolsAndroidLayout Inspector. Learn more.
    Layout Inspector


    • Device File Explorer - Ported from DDMS into Android Studio by popular demand, the new Device File Explorer allows you to view the file and directory structure of your Android device or emulator. As you are testing your app, you can now quickly preview and modify app data files directly in Android Studio.

    Device File Explorer



    Optimize

    • Android Profiler - Android Studio 3.0 includes a brand new suite of tools to help debug performance problems in your app. We completely rewrote the previous set of Android Monitor tools, and replaced them with the Android Profiler. Once you deploy your app to a running device or emulator, click on the Android Profiler tab and you will now have access to a real-time & unified view of the CPU, Memory, & Network activity for your app. Each of the performance events are mapped to the UI event timeline which highlights touch events, key presses, and activity changes so that you have more context on when and why a certain event happened.  Click on each timeline to dig into each performance aspect of your app. Learn more

    Android Profiler - Combined timeline view.

    • CPU Profiler - Unnecessary CPU processing and load spikes are symptoms of poor app performance. With the CPU Profiler, you can analyze the CPU thread usage of your app by triggering a sample or instrumented CPU trace. At this point, you can troubleshoot CPU performance issues using a variety of data views and filters built into the CPU Profiler. Learn more.

    CPU Profiler


    • Memory Profiler - Using memory inefficiently can lead to many device problems ranging from a janky UI to low memory events. The Memory Profiler combines the functionality of the previous Heap Viewer and Allocation Tracker in one rich interface to help debug memory usage problems in your app. You can diagnose a range of memory issues by analyzing memory allocations, heap dumps and more. Learn more.

    Memory Profiler



    • Network Profiler - Optimizing foreground and background network usage in your app can lead to a more performant app and lower app data usage. The network profiler allows you to monitor the network activity of your app, inspect the payload of each of your network requests, and link back to the line of source code that generated the network request. Currently, the network profiler works with HttpURLConnection, OkHttp, and Volley network libraries. The network profiler is an advanced analysis feature that can be enabled on Pre-Android O devices & emulators by selecting Enable Advanced Profiling in the Profiling Tab in the Run Configuration box. In addition to enabling network request and payload analysis, this checkbox enables event collection at the top level, memory object count, and memory garbage collection. For Android O-based devices and emulator, just deploy your app. Learn more.
    Network Profiler




    Network Profiler Setup for Pre- Android O Devices


    • APK Analyzer Improvements - In Android Studio 3.0, we have added some additional enhancements to the APK Analyzer to help you further optimize the size of your APK. With this feature update, you can now analyze Instant App zip files & AARs, and view dex bytecode of classes & methods. You can also generate Proguard configuration rules and load Proguard mapping files in the dex viewer. Learn more.

    APK Analyzer
    Check out the release notes for more details.

    Getting Started  

    Download

    If you are using a previous version of Android Studio, you can install Android Studio 3.0 Canary 1 alongside your stable version. You can download this update from the official Android Studio Preview download page. As mention in this blog, there are some breaking Gradle Plugin API changes to support new features in the IDE. Therefore, you should also update your Android Gradle plugin version to 3.0.0-alpha1 in your current project to test and validate your app project setup.


    We appreciate any feedback on things you like, issues or features you would like to see. If you find a bug or issue, feel free to file an issue. Connect with us -- the Android Studio development team ‐ on our Google+ page or on Twitter.




    What’s New in Android: O Developer Preview 2 & More

    Posted by: Dave Burke, VP of Engineering

    android-o-logo.png
    With billions of Android devices around the world, Android has surpassed our wildest expectations. Today at Google I/O, we showcased a number of ways we’re pushing Android forward, with the O Release, new tools for developers to help create more performant apps, and an early preview of a project we call Android Go -- a new experience that we’re building for entry-level devices.
    Fluid experiences in Android O
    It's pretty incredible what you can do on mobile devices today, and how easy it is to rely on them as computers in our pockets. In the O release we've focused on creating fluid experiences that make Android even more powerful and easy to use, and today we highlighted some of those:
    • Picture-in-picture: lets users manage two tasks simultaneously, whether it’s video calling your friend while checking your calendar, or reading a new recipe while watching a video on a specific cooking technique. We’ve designed PIP to provide seamless multitasking on any size screen, and it’s easy for apps to support it.
    • Notification dots extend the reach of notifications, a new way for developers to surface activity in their app, driving engagement. Built on our unique and highly regarded notification system, dots work with zero effort for most apps - we even extract the color of the dot from your icon. 
    • Autofill with Google simplifies setting up a new device and synchronizing passwords by bringing Chrome's Autofill feature to Android. Once a user opts-in, Autofill will work out-of-the-box for most apps. Developers can optimize their apps for Autofill by providing hints about the type of data expected or add support in custom views. 
    • A new homescreen for Android TV makes it easy for users to find, preview, and watch content provided by apps. Apps can publish one or more channels, and users can control the channels that appear on the homescreen. You’ll be able to get started with creating channels using the new TvProvider support library APIs
    • Smart Text Selection: In Android O, we’re applying on-device machine learning to copy/paste, to let Android recognize entities like addresses, URLs, telephone numbers, and email addresses. This makes the copy/paste experience better by selecting the entire entity and surfacing the right apps to carry out an action based on the type of entity.
    • TensorFlow Lite: As Android continues to take advantage of machine learning to improve the user experience, we want our developer partners to be able to do the same. Today we shared an early look at TensorFlow Lite, an upcoming project based on TensorFlow, Google’s open source machine learning library. TensorFlow Lite is specifically designed to be fast and lightweight for embedded use cases. Since many on-device scenarios require real-time performance, we’re also working on a new Neural Network API that TensorFlow can take advantage of to accelerate computation. We plan to make both of these available to developers in a maintenance update to O later this year, so stay tuned!  
    (L) Android O: Picture-in-picture, (R) Android O: Notification dots

    Working on the Vitals in Android
    We think Android’s foundations are critical, so we’re investing in Android Vitals, a project focused on optimizing battery life, startup time, graphic rendering time, and stability. Today we showcased some of the work we’ve done so far, and introduced new tools to help developers understand power, performance, and reliability issues in their apps:
    • System optimizations: in Android O, we’ve done a lot of work across the system to make apps run faster and smoother. For example we made extensive changes in our runtime - including new optimizations like concurrent compacting garbage collection, code locality, and more. 
    • Background limits: up to now it’s been fairly easy for apps to unintentionally overuse resources while they’re in the background, and this can adversely affect the performance of the system. So in O, we've introduced new limits on background location and wi-fi scans, and changes in the way apps run in the background. These boundaries prevent overuse -- they’re about increasing battery life and freeing up memory.
    • New Android Vitals Dashboards in the Play Console: today we launched six Play Console dashboards to help you pinpoint common issues in your apps - excessive crash rate, ANR rate, frozen frames, slow rendering, excessive wakeups, and stuck wake locks, including how many users are affected, with guidance on the best way to address the issues. You can visit the Play Console today to see your app's data, then learn how to address any issues.
    Android Go
    Part of Android’s mission is to bring computing to everyone. We’re excited about seeing more users come online for the first time as the price of entry level smart phones drop, and we want to help manufacturers continue to offer lower-cost devices that provide a great experience for these users. Today we gave a sneak peek of a new experience that we’re building specifically for Android devices that have 1GB or less of memory -- Internally we call it “Android Go,” and it’s designed around three things
    • OS: We’re optimizing Android O to run smoothly and efficiently on entry-level devices
    • Apps: We’re also designing Google apps to use less memory, storage space, and mobile data, including apps such as YouTube Go, Chrome, and Gboard. 
    • Play: On entry-level devices, Play store will promote a better user experience by highlighting apps that are specifically designed for these devices -- such as apps that use less memory, storage space, and mobile data -- while still giving users access to the entire app catalog.
    The Android Go experience will ship in 2018 for all Android devices that have 1GB or less of memory. We recommend getting your apps ready for these devices soon -- take a look at the Building for Billions to learn about the importance of offering a useful offline state, reducing APK size, and minimizing battery and memory use.

    O Developer Preview 2, Now in Public Beta
    Today’s release of O Developer Preview 2 is our first beta-quality candidate, available to test on your primary phone or tablet. We’re inviting those who want to try the beta release of Android O to enroll now at android.com/beta -- it’s an incredibly convenient way to preview Android O on your Nexus 5X, 6P, and Player, as well as Pixel, Pixel XL, or Pixel C device.

    With more users starting to get Android O on their devices through the Android Beta program, now is the time to test your apps for compatibility, resolve any issues, and publish an update as soon as possible. See the migration guide for steps and a recommended timeline.

    Later today you’ll be able to download the updated tools for developing on Android O, including the latest canaries of Android Studio, SDK, and tools, Android O system images, and emulators. Along with those, you’ll be able to download support library 26.0.0 beta and other libraries from our new Maven repo. The change to Maven from SDK Manager means a slight change to your build configuration, but gives you much more flexibility in how you integrate library updates with your CI systems.

    When you’re ready to get started developing with Android O, visit the O Developer Preview site for details on all of the features you can use in your apps, including notification channels and dots, picture-in-picture, autofill, and others. APIs have changed since the first developer preview, so take a look at the diff report to see where your code might be affected.

    Thanks for the feedback you’ve given us so far. Please keep it coming, about Android O features, APIs, issues, or requests -- see the Feedback and Bugs page for details on where to report feedback.

    Introducing Android Native Development Kit r14

    Posted by Dan Albert, Android NDK Tech Lead

    Android NDK r14


    The latest version of the Android Native Development Kit (NDK), Android NDK r14, is now available for download. It is also available in the SDK manager via Android Studio.

    So what's new in r14? The full changelog can be seen here, but the highlights include the following:
    • Updated all the platform headers to unified headers (covered in detail below)
    • LTO with Clang now works on Darwin and Linux
    • libc++ has been updated. You can now use thread_local for statics with non-trivial destructors (Clang only)
    • RenderScript is back!

    Unified Headers

    We've completely redone how we ship platform header files in the NDK. Rather than having one set of headers for every target API level, there's now a single set of headers. The availability of APIs for each Android platform is guarded in these headers by #if __ANDROID_API__ >= __ANDROID_API_FOO__ preprocessor directives.

    The prior approach relied on periodically-captured snapshots of the platform headers. This meant that any time we fixed a header-only bug, the fix was only available in the latest version aside from the occasional backport. Now bugfixes are available regardless of your NDK API level.

    Aside from bugfixes, this also means you'll have access to modern Linux UAPI headers at every target version. This will mostly be important for people porting existing Linux code (especially low-level things). Something important to keep in mind: just because you have the headers doesn't mean you're running on a device with a kernel new enough to support every syscall. As always with syscalls, ENOSYS is a possibility.

    Beyond the Linux headers, you'll also have modern headers for OpenGL, OpenSLES, etc. This should make it easier to conditionally use new APIs when you have an older target API level. The GLES3 headers are now accessible on Ice Cream Sandwich even though that library wasn't available until KitKat. You will still need to use all the API calls via dlopen/dlsym, but you'll at least have access to all the constants and #defines that you would need for invoking those functions.
    Note that we'll be removing the old headers from the NDK with r16, so the sooner you file bugs, the smoother the transition will go.

    Caveats

    The API #ifdef guards do not exist in third-party headers like those found in OpenGL. In those cases you'll receive a link time error (undefined reference) rather than a compile time error if you use an API that is not available in your targeted API level.

    Standalone toolchains using GCC are not supported out of the box (nor will they be). To use GCC, pass -D__ANDROID_API__=$API when compiling.

    Enabling Unified Headers in Your Build

    To ease the transition from the legacy headers to the unified headers, we haven't enabled the new headers by default, though we'll be doing this in r15. How you opt-in to unified headers will depend on your build system.

    ndk-build


    In your Application.mk:

        APP_UNIFIED_HEADERS := true
    
    You can also set this property from the command-line like this:

        $ ndk-build APP_UNIFIED_HEADERS=true
    

    If you're using ndk-build via Gradle with externalNativeBuild, specify the following configuration settings in build.gradle:

        android {
          ...
          defaultConfig {
            ...
            externalNativeBuild {
              ndkBuild {
                ...
                arguments "APP_UNIFIED_HEADERS=true"
              }
            }
          }
        }
    

    CMake

    When configuring your build, set ANDROID_UNIFIED_HEADERS=ON. This will usually take the form of invoking CMake with cmake -DANDROID_UNIFIED_HEADERS=ON $OTHER_ARGS.

    If you're using CMake via Gradle with externalNativeBuild, you can use:

        android {
          ...
          defaultConfig {
            ...
            externalNativeBuild {
              cmake {
                ...
                arguments "-DANDROID_UNIFIED_HEADERS=ON"
              }
            }
          }
        }
    

    Standalone Toolchains

    When creating your standalone toolchain, pass --unified-headers. Note that this option is not currently available in the legacy script, make-standalone-toolchain.sh, but only in make_standalone_toolchain.py.

    Experimental Gradle Plugin

    Coming soon! Follow along here.

    Custom Build System?

    We've got you covered. Instructions on adding support for unified headers to your build system can be found here.

    For additional information about unified headers, see our docs and the tracking bug. If you're looking ahead to future releases, the most up-to-date version of the documentation is in the master branch.

    O-MG, the Developer Preview of Android O is here!

    Posted by Dave Burke, VP of Engineering

    Since the first launch in 2008, the Android project has thrived on the incredible feedback from our vibrant ecosystems of app developers and device makers, as well as of course our users. More recently, we've been pushing hard on improving our engineering processes so we can share our work earlier and more openly with our partners.

    So, today, I'm excited to share a first developer preview of the next version of the OS: Android O. The usual caveats apply: it's early days, there are more features coming, and there's still plenty of stabilization and performance work ahead of us. But it's booting :).

    Over the course of the next several months, we'll be releasing updated developer previews, and we'll be doing a deep dive on all things Android at Google I/O in May. In the meantime, we'd love your feedback on trying out new features, and of course testing your apps on the new OS.

    What's new in O?

    Android O introduces a number of new features and APIs to use in your apps. Here's are just a few new things for you to start trying in this first Developer Preview:

    Background limits: Building on the work we began in Nougat, Android O puts a big priority on improving a user's battery life and the device's interactive performance. To make this possible, we've put additional automatic limits on what apps can do in the background, in three main areas: implicit broadcasts, background services, and location updates. These changes will make it easier to create apps that have minimal impact on a user's device and battery. Background limits represent a significant change in Android, so we want every developer to get familiar with them. Check out the documentation on background execution limits and background location limits for details.

    Notification channels: Android O also introduces notification channels, which are new app-defined categories for notification content. Channels let developers give users fine-grained control over different kinds of notifications — users can block or change the behavior of each channel individually, rather than managing all of the app's notifications together.

    Notification channels let users control your app's notification categories

    Android O also adds new visuals and grouping to notifications that make it easier for users to see what's going on when they have an incoming message or are glancing at the notification shade.

    Autofill APIs: Android users already depend on a range of password managers to autofill login details and repetitive information, which makes setting up new apps or placing transactions easier. Now we are making this work more easily across the ecosystem by adding platform support for autofill. Users can select an autofill app, similar to the way they select a keyboard app. The autofill app stores and secures user data, such as addresses, user names, and even passwords. For apps that want to handle autofill, we're adding new APIs to implement an Autofill service.

    PIP for handsets and new windowing features: Picture in Picture (PIP) display is now available on phones and tablets, so users can continue watching a video while they're answering a chat or hailing a car. Apps can put themselves in PiP mode from the resumed or a pausing state where the system supports it - and you can specify the aspect ratio and a set of custom interactions (such as play/pause). Other new windowing features include a new app overlay window for apps to use instead of system alert window, and multi-display support for launching an activity on a remote display.

    Font resources in XML: Fonts are now a fully supported resource type in Android O. Apps can now use fonts in XML layouts as well as define font families in XML — declaring the font style and weight along with the font files.

    Adaptive icons: To help you integrate better with the device UI, you can now create adaptive icons that the system displays in different shapes, based on a mask selected by the device. The system also animates interactions with the icons, and them in the launcher, shortcuts, Settings, sharing dialogs, and in the overview screen.

    Adaptive icons display in a variety of shapes across different device models.

    Wide-gamut color for apps: Android developers of imaging apps can now take advantage of new devices that have a wide-gamut color capable display. To display wide gamut images, apps will need to enable a flag in their manifest (per activity) and load bitmaps with an embedded wide color profile (AdobeRGB, Pro Photo RGB, DCI-P3, etc.).

    Connectivity: For the ultimate in audio fidelity, Android O now also supports high-quality Bluetooth audio codecs such as LDAC codec. We're also adding new Wi-Fi features as well, like Wi-Fi Aware, previously known as Neighbor Awareness Networking (NAN). On devices with the appropriate hardware, apps and nearby devices can discover and communicate over Wi-Fi without an Internet access point. We're working with our hardware partners to bring Wi-Fi Aware technology to devices as soon as possible.

    The Telecom framework is extending ConnectionService APIs to enable third party calling apps integrate with System UI and operate seamlessly with other audio apps. For instance, apps can have their calls displayed and controlled in different kinds of UIs such as car head units.

    Keyboard navigation: With the advent of Google Play apps on Chrome OS and other large form factors, we're seeing a resurgence of keyboard navigation use within these apps. In Android O we focused on building a more reliable, predictable model for "arrow" and "tab" navigation that aids both developers and end users.

    AAudio API for Pro Audio: AAudio is a new native API that's designed specifically for apps that require high-performance, low-latency audio. Apps using AAudio read and write data via streams. In the Developer Preview we're releasing an early version of this new API to get your feedback.

    WebView enhancements: In Android Nougat we introduced an optional multiprocess mode for WebView that moved the handling of web content into an isolated process. In Android O, we're enabling multiprocess mode by default and adding an API to let your app handle errors and crashes, for enhanced security and improved app stability. As a further security measure, you can now opt in your app's WebView objects to verify URLs through Google Safe Browsing.

    Java 8 Language APIs and runtime optimizations: Android now supports several new Java Language APIs, including the new java.time API. In addition, the Android Runtime is faster than ever before, with improvements of up to 2x on some application benchmarks.

    Partner platform contributions: Hardware manufacturers and silicon partners have accelerated fixes and enhancements to the Android platform in the O release. For example, Sony has contributed more than 30 feature enhancements including the LDAC codec and 250 bug fixes to Android O.

    Get started in a few simple steps

    First, make your app compatible to give your users a seamless transition to Android O. Just download a device system image or emulator system image, install your current app, and test -- the app should run and look great, and handle behavior changes properly. After you've made any necessary updates, we recommend publishing to Google Play right away without changing the app's platform targeting.

    Building with Android O

    When you're ready, dive in to O in depth to learn about everything you can take advantage of for your app. Visit the O Developer Preview site for details on the preview timeline, behavior changes, new APIs, and support resources.

    Plan how your app will support background limits and other changes. Try out some of the great new features in your app -- notification channels, PIP, adaptive icons, font resources in XML, autosizing TextView, and many others. To make it easier to explore the new APIs in Android O, we've brought the API diff report online, along with the Android O API reference.

    The latest canary version of Android Studio 2.4 includes new features to help you get started with Android O. You can download and set up the O preview SDK from inside Android Studio, then use Android O's XML font resources and autosizing TextView in the Layout Editor. Watch for more Android O support coming in the weeks ahead.

    We're also releasing an alpha version of the 26.0.0 support library for you to try. This version adds new APIs and bug fixes and increases the minSdkversion to 14.

    Preview updates

    The O Developer Preview includes an updated SDK with system images for testing on the official Android Emulator and on Nexus 5X, Nexus 6P, Nexus Player, Pixel, Pixel XL and Pixel C devices. If you're building for wearables, there's also an emulator for testing Android Wear 2.0 on Android O.

    We plan to update the preview system images and SDK regularly throughout the O Developer Preview. This initial preview release is for developers only and not intended for daily or consumer use, so we're making it available by manual download and flash only. Downloads and instructions are here.

    As we get closer to a final product, we'll be inviting consumers to try it out as well, and we'll open up enrollments through Android Beta at that time. Stay tuned for details, but for now please note that Android Beta is not currently available for Android O.

    Give us your feedback

    As always, your feedback is crucial, so please let us know what you think — the sooner we hear from you, the more of your feedback we can integrate. When you find issues, please report them here. We've moved to a more robust tool, Issue Tracker, which is also used internally at Google to track bugs and feature requests during product development. We hope you'll find it easier to use.

    Keeping up to Date with the the Support Library

    Posted by Agustin Fonts, Product Manager, Android Support Library

    It's important to keep current when you're dealing with technology. That’s why we're constantly working to improve the quality of our software, particularly libraries that are linked into your apps, such as the Support Library.  The Support Library is a suite of libraries that provides backward compatibility along with additional features across many Android releases.


    We have just released version 25.2 of the Support Library.  If you're making use of the android.support.v7.media.MediaRouter class in revision 25.1.1 or 25.1.0, we strongly recommend that you update due to a known issue.  If you haven't updated recently, you've missed out on some great bug fixes such as these:


    25.2:
    • Corrected a severe mediarouter issue in which using an A2DP Bluetooth device and media routing APIs could cause the device to become unresponsive, requiring a reboot
    • Showing a slide presentation with screen mirroring no longer causes the device to disconnect from Wi-Fi
    • Media button now properly handles media apps that did not register themselves with setMediaButtonReceiver()
    • TextInputLayout correctly overlays hint and text if text is set by XML (AOSP issue 230171)
    • Corrected a memory leak in MediaControllerCompat (AOSP issue 231441)
    • RecyclerView no longer crashes when recycling view holders (AOSP issue 225762)

    Reporting (and fixing) a Bug


    The Support Library is developed by the Android Framework and Developer Relations teams, and, just like the Android platform, you can file bugs using the AOSP issue tracker, or submit fixes to our Git repository. Your feedback is critical in helping us to make the Support Library the most productive environment to use for developing Android applications.

    Build flexible layouts with FlexboxLayout

    Posted by Takeshi Hagikura, Developer Programs Engineer

    At Google I/O last year we announced ConstraintLayout, which enables you to build complex layouts while maintaining a flat view hierarchy. It is also fully supported in Android Studio's Visual Layout Editor.

    At the same time, we open sourced FlexboxLayout to bring the same functionalities of the CSS Flexible Layout module to Android. Here are some cases where FlexboxLayout is particularly effective.

    FlexboxLayout can be interpreted as an advanced LinearLayout because both layouts align their child views sequentially. The significant difference between LinearLayout and FlexboxLayout is that FlexboxLayout has a feature for wrapping.

    That means if you add the flexWrap="wrap" attribute, FlexboxLayout puts a view to a new line if there is not enough space left in the current line as shown in the picture below.


    One layout for various screen sizes

    With that characteristic in mind, let's take a case where you want to put views sequentially but have them move to new lines if the available space changes (due to a device factor, orientation changes or the window resizing in the multi-window mode).


    Nexus5X portrait


    Nexus5X landscape

    Pixel C with multi window mode enabled, divider line on the left.


    Pixel C with multi window mode enabled, divider line on the middle.


    Pixel C with multi window mode enabled, divider line on the right.

    You would need to define multiple DP-bucket layouts (such as layout-600dp, layout-720dp, layout-1020dp) to handle various screen sizes with traditional layouts such as LinearLayout or RelativeLayout. But the dialog above is built with a single FlexboxLayout.

    The technique used in the example is setting the flexWrap="wrap" as explained above,

    <com .google.android.flexbox.flexboxlayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         app:flexwrap="wrap">
    then you can get the following layout where child views are aligned to a new line instead of overflowing its parent.




    Another technique I'd like to highlight is setting the layout_flexGrow attribute to an individual child. This helps improve the look of the final layout when free space is left over. The layout_flexGrow attribute works similar to the layout_weight attribute in LinearLayout. That means FlexboxLayout will distribute the remaining space according to the layout_flexGrow value set to each child in the same line.

    In the example below, it assumes each child has the layout_flexGrow attribute set to 1, so free space will be evenly distributed to each of them.
     <android .support.design.widget.TextInputLayout
         android:layout_width="100dp"
         android:layout_height="wrap_content" 
         app:layout_flexgrow="1">



    You can check out the complete layout xml file in the GitHub repository.

    RecyclerView integration 

    Another advantage of FlexboxLayout is that it can be integrated with RecyclerView. With the latest release of the alpha version the new FlexboxLayoutManager extends RecyclerView.LayoutManager, now you can make use of the Flexbox functionalities in a scrollable container in much more memory-efficient way.

    Note that you can still achieve a scrollable Flexbox container with FlexboxLayout wrapped with ScrollView. But, you will be likely to experience jankiness or even an OutOfMemoryError if the number of items contained in the layout is large, as FlexboxLayout doesn't take view recycling into account for the views that go off the screen as the user scrolls.

    (If you would like to learn more about the RecyclerView in details, you can check out the videos from the Android UI toolkit team such as 1, 2)

    A real world example where the RecyclerView integration is useful is for apps like the Google Photos app or News apps, both expect large number of items while needing to handle various width of items.

    One example is found in the demo application in the FlexboxLayout repository. As you can see in the repository, each image shown in RecyclerView has a different width. But by setting the flexWrap setting to wrap,

    FlexboxLayoutManager layoutManager = new FlexboxLayoutManager();
    layoutManager.setFlexWrap(FlexWrap.WRAP);
    and setting the flexGrow (as you can see, you can configure the attributes through FlexboxLayoutManager and FlexboxLayoutManager.LayoutParams for child attributes instead of configuring it from xml) attribute to a positive value for each child,
    void bindTo(Drawable drawable) {
      mImageView.setImageDrawable(drawable);
      ViewGroup.LayoutParams lp = mImageView.getLayoutParams();
      if (lp instanceof FlexboxLayoutManager.LayoutParams) {
        FlexboxLayoutManager.LayoutParams flexboxLp = 
            (FlexboxLayoutManager.LayoutParams) mImageView.getLayoutParams();
        flexboxLp.setFlexGrow(1.0f);
      }
    }
    you can see every image fits within the layout nicely regardless of the screen orientation.



    If you would like to see complete FlexboxLayout example, you can check:


    What's next?

    Check out the full documentation for other attributes to build flexible layouts tailored for your needs. We're very open to hear your feedback, if you find any issues or feature requests, please file an issue on the GitHub repository.



    Get a sneak peek at Android Nougat 7.1.2

    Posted by Dave Burke, VP of Engineering

    The next maintenance release for Android Nougat -- 7.1.2 -- is just around the corner! To get the recipe just right, starting today, we're rolling out a public beta to eligible devices that are enrolled in the Android Beta Program, including Pixel and Pixel XL, Nexus 5X, Nexus Player, and Pixel C devices. We're also preparing an update for Nexus 6P that we expect to release soon.

    Android 7.1.2 is an incremental maintenance release focused on refinements, so it includes a number of bugfixes and optimizations, along with a small number of enhancements for carriers and users.

    If you'd like to try the public beta for Android 7.1.2, the easiest way is through the Android Beta Program. If you have an eligible device that's already enrolled, you're all set -- your device will get the public beta update in the next few days and no action is needed on your part. If your device isn't enrolled, it only takes a moment to visit android.com/beta and opt-in your eligible Android phone or tablet -- you'll soon receive the public beta update over-the-air. As always, you can also download and flash this update manually.

    We're expecting to launch the final release of the Android 7.1.2 in just a couple of months, Like the beta, it will be available for for Pixel, Pixel XL, Nexus 5X, Nexus 6P, Nexus Player, and Pixel C devices. Meanwhile we welcome your feedback or requests in the Android Beta community as we work towards the final over-the-air update. Thanks for being part of the public beta!