Category Archives: Google Developers Blog

News and insights on Google platforms, tools and events

13 Most Common Google Cloud Reference Architectures

Posted by Priyanka Vergadia, Developer Advocate

Google Cloud is a cloud computing platform that can be used to build and deploy applications. It allows you to take advantage of the flexibility of development while scaling the infrastructure as needed.

I'm often asked by developers to provide a list of Google Cloud architectures that help to get started on the cloud journey. Last month, I decided to start a mini-series on Twitter called “#13DaysOfGCP" where I shared the most common use cases on Google Cloud. I have compiled the list of all 13 architectures in this post. Some of the topics covered are hybrid cloud, mobile app backends, microservices, serverless, CICD and more. If you were not able to catch it, or if you missed a few days, here we bring to you the summary!

Series kickoff #13DaysOfGCP

#1: How to set up hybrid architecture in Google Cloud and on-premises

Day 1

#2: How to mask sensitive data in chatbots using Data loss prevention (DLP) API?

Day 2

#3: How to build mobile app backends on Google Cloud?

Day 3

#4: How to migrate Oracle Database to Spanner?

Day 4

#5: How to set up hybrid architecture for cloud bursting?

Day 5

#6: How to build a data lake in Google Cloud?

Day 6

#7: How to host websites on Google Cloud?

Day 7

#8: How to set up Continuous Integration and Continuous Delivery (CICD) pipeline on Google Cloud?

Day 8

#9: How to build serverless microservices in Google Cloud?

Day 9

#10: Machine Learning on Google Cloud

Day 10

#11: Serverless image, video or text processing in Google Cloud

Day 11

#12: Internet of Things (IoT) on Google Cloud

Day 12

#13: How to set up BeyondCorp zero trust security model?

Day 13

Wrap up with a puzzle

Wrap up!

We hope you enjoy this list of the most common reference architectures. Please let us know your thoughts in the comments below!

Simpler Google Pay integration for React and web developers

Posted by Soc Sieng, Developer Advocate

The Google Pay API enables fast, simple checkout for your website.

The Google Pay JavaScript library does not depend on external libraries or frameworks and will work regardless of which framework your website uses (if it uses any at all). While this ensures wide compatibility, we know that it doesn’t necessarily make it easier to integrate when your website uses a framework. We’re doing something about it.

Introducing the Google Pay button for React

React is one of the most widely-used tools for building web UI's, so we are launching the Google Pay Button for React to provide a streamlined integration experience. This component will make it easier to incorporate Google Pay into your React website whether you are new to React or a seasoned pro, and similarly, if this is your first Google Pay integration or if you’ve done this before.

We’re making this component available as an open source project on GitHub and publishing it to npm. We’ve authored the React component with TypeScript to bring code completion to supported editors, and if your website is built with TypeScript you can also take advantage of type validation to identify common issues as you type.

Get real time code completion and validation as you integrate with supported editors.

Getting started

The first step is to install the Google Pay button module from npm:

npm install @google-pay/button-react

Adding and configuring the button

The Google Pay button can be added to your React component by first importing it:

import GooglePayButton from '@google-pay/button-react';

And then rendering it with the necessary configuration values:

<GooglePayButton
environment="TEST"
paymentRequest={{ ... }}
onLoadPaymentData={() => {}}
/>

Try it out for yourself on JSFiddle.

Refer to component documentation for a full list of supported configuration properties.

Note that you will need to provide a Merchant ID in paymentRequest.merchantInfo to complete the integration. Your Merchant ID can be obtained from the Google Pay Business Console.

Your Merchant ID can be found in the Google Pay Business Console.

Support for other frameworks

We also want to provide an improved developer experience for our developers using other frameworks, or no framework at all. That’s why we are also releasing the Google Pay button Custom Element.

Custom elements are great because:

Like the React component, the Google Pay button custom element is hosted on GitHub and published to npm. In fact, the React component and the custom element share the same repository and large portion of code. This ensures that both versions maintain feature parity and receive the same level of care and attention.

Try it out on JSFiddle.

Google Pay JavaScript library

There's no change to the existing Google Pay JavaScript library, and if you prefer, you can continue to use this directly instead of the React component or custom element. Both of these components provide a convenience layer over the Google Pay JavaScript library and make use of it internally.

Your feedback

This is the first time that we (the Google Pay team) have released a framework specific library. We would love to hear your feedback.

Aside from React, most frameworks can use the Web Component version of the Google Pay Button. We may consider adding support for other frameworks based on interest and demand.

If you encounter any problems with the React component or custom element, please raise a GitHub issue. Alternatively, if you know what the problem is and have a solution in mind, feel free to raise a pull request. For other Google Pay related requests and questions, use the Contact Support option in the Google Pay Business Console.

What do you think?

Do you have any questions? Let us know in the comments below or tweet using #AskGooglePayDev.

Simpler Google Pay integration for React and web developers

Posted by Soc Sieng, Developer Advocate

The Google Pay API enables fast, simple checkout for your website.

The Google Pay JavaScript library does not depend on external libraries or frameworks and will work regardless of which framework your website uses (if it uses any at all). While this ensures wide compatibility, we know that it doesn’t necessarily make it easier to integrate when your website uses a framework. We’re doing something about it.

Introducing the Google Pay button for React

React is one of the most widely-used tools for building web UI's, so we are launching the Google Pay Button for React to provide a streamlined integration experience. This component will make it easier to incorporate Google Pay into your React website whether you are new to React or a seasoned pro, and similarly, if this is your first Google Pay integration or if you’ve done this before.

We’re making this component available as an open source project on GitHub and publishing it to npm. We’ve authored the React component with TypeScript to bring code completion to supported editors, and if your website is built with TypeScript you can also take advantage of type validation to identify common issues as you type.

Get real time code completion and validation as you integrate with supported editors.

Getting started

The first step is to install the Google Pay button module from npm:

npm install @google-pay/button-react

Adding and configuring the button

The Google Pay button can be added to your React component by first importing it:

import GooglePayButton from '@google-pay/button-react';

And then rendering it with the necessary configuration values:

<GooglePayButton
environment="TEST"
paymentRequest={{ ... }}
onLoadPaymentData={() => {}}
/>

Try it out for yourself on JSFiddle.

Refer to component documentation for a full list of supported configuration properties.

Note that you will need to provide a Merchant ID in paymentRequest.merchantInfo to complete the integration. Your Merchant ID can be obtained from the Google Pay Business Console.

Your Merchant ID can be found in the Google Pay Business Console.

Support for other frameworks

We also want to provide an improved developer experience for our developers using other frameworks, or no framework at all. That’s why we are also releasing the Google Pay button Custom Element.

Custom elements are great because:

Like the React component, the Google Pay button custom element is hosted on GitHub and published to npm. In fact, the React component and the custom element share the same repository and large portion of code. This ensures that both versions maintain feature parity and receive the same level of care and attention.

Try it out on JSFiddle.

Google Pay JavaScript library

There's no change to the existing Google Pay JavaScript library, and if you prefer, you can continue to use this directly instead of the React component or custom element. Both of these components provide a convenience layer over the Google Pay JavaScript library and make use of it internally.

Your feedback

This is the first time that we (the Google Pay team) have released a framework specific library. We would love to hear your feedback.

Aside from React, most frameworks can use the Web Component version of the Google Pay Button. We may consider adding support for other frameworks based on interest and demand.

If you encounter any problems with the React component or custom element, please raise a GitHub issue. Alternatively, if you know what the problem is and have a solution in mind, feel free to raise a pull request. For other Google Pay related requests and questions, use the Contact Support option in the Google Pay Business Console.

What do you think?

Do you have any questions? Let us know in the comments below or tweet using #AskGooglePayDev.

Local Home SDK support on Nest WiFi

Posted by Toni Klopfenstein, Developer Advocate

Today, we're expanding the support of the Local Home SDK to the Google Nest Wifi routers with the latest firmware update to M81. The Local Home SDK we recently launched allows you to create a local fulfilment path for your smart home Action. Local fulfillment provides lower latency and higher reliability for your smart home Action.

By adding support for the Node.js runtime of the Nest WiFi routers, the Local Home platform is now compatible with the full Nest WiFi system. This update means your local execution application can run on a self-healing mesh wireless network, and your users gain the benefits of expanded reliable home automation coverage.

To support this additional runtime, we've updated the Actions Console to enable you to add the Node.js on-device testing URL. The Nest WiFi routers will receive the the node-targeted bundle.js files you've already uploaded during deployment of your Action automatically. Since Chrome DevTools have built-in Node.js support, your development flow doesn't require any additional tools for inspecting your Node.js app or debugging your smart home Action.

We have updated the developer guide and tools to help guide you through the various local fulfilment runtimes and features of these toolings. For additional guidance on enabling local fulfilment for your smart home Action, check out the Enable local fulfillment for smart home Actions codelab. The API reference and samples can also help you build your first local fulfilment app.

We want to hear from you! Continue sharing your feedback with us through the issue tracker, and engage with other smart home developers in the /r/GoogleAssistantDev community. Follow @ActionsOnGoogle on Twitter for more of our team's updates, and tweet using #AoGDevs to share what you’re working on. We can’t wait to see what you build!

Voice Global 2020: New improvements to core platform and development tools for Google Assistant

Posted by Payam Shodjai, Director of Product Management, Google Assistant

Today at VOICE Global, we shared our vision for Google Assistant to truly be the best way to get things done - and the important role that developers play in that vision, especially as voice experiences continue to evolve.

Google Assistant helps more than 500 million people every month in over 30 languages across 90 countries get things done at home and on the go. What’s at the heart of this growth is the simple insight that people want a more natural way to get what they need. That’s why we’ve invested heavily in making sure Google Assistant works seamlessly across devices and services and offers quick and accurate help.

Over the last few months, we’ve seen people’s needs shifting, and this is reflected in how Google Assistant is being used and the role that it can play to help navigate these changes. For example, to help people get accurate information on Search and Maps - like modified store hours or information on pick-up and delivery - we have been using Duplex conversational technology to contact businesses and update over half a million business listings.

We’ve also been working with our partners to bring great educational experiences into the home, so that families can continue learning in a communal setting. Bamboo Learning is bringing their voice-forward education platform to Google Assistant, with fun, new ways to learn history, math, and reading. Our hand-washing songs continue to be popular. The songs leverage WaveNet's natural expressiveness – allowing us to train Google Assistant to sing across numerous generated voices users can pick from.

Building Google Assistant experiences gets easier

Great experiences are at the core of what makes Google Assistant truly helpful. To help existing and aspiring developers build new experiences with ease, we are making some major improvements to our core platform and development tools. Rather than needing to hop back and forth between Actions Console and Dialogflow to build an Action, wouldn’t it be great if there were one integrated platform for building on Google Assistant?

Starting today, we’re releasing Actions Builder, a new web-based IDE that provides a graphical interface to show the entire conversation flow. It allows you to manage Natural Language Understanding (NLU) training data and provides advanced debugging tools. And, it is fully integrated into the Actions Console so you can now build, debug, test, release, and analyze your Actions - all in one place.

If you prefer to work in your own tools, you can use the updated Actions SDK. For the first time, you’ll have a file based representation of your action and the ability to use a local IDE. The SDK not only enables local authoring of NLU and conversation schemas, but it also allows bulk import and export of training data to improve conversation quality. The Actions SDK is accompanied by a command line interface, so you can build and manage an action fully in code using your favorite source control and continuous integration tools.

With these two releases, we are also introducing a new conversation model and improvements to the runtime engine. Now, it’s easier to design and build conversations and users will get faster and more accurate responses. We’re very excited about this suite of products which replaces Dialogflow as the preferred way to develop conversational actions on Google Assistant.

New functionality to create interactive voice actions

Based on feedback from developers, we’re also adding new functionality to build more interactive experience on Google Assistant with Home Storage, updated Media API and Continuous Match Mode.

One of the exciting things about speakers and smart displays is that they’re communal. Home Storage is a new feature that provides a communal storage solution for devices connected on the home graph and allows developers to save context for all individual users, such as the last saved point from a puzzle game.

Our updated Media APIs now support longer-form media sessions and lets users resume playback of content across surfaces. For example, users can start playback from a specific moment or resume where they dropped out of their previous session.

Sometimes you want to build experiences that enable users to speak more naturally with your action, without waiting for a change in mic states. Rolling out in the next few months, Continuous Match Mode allows Assistant to respond immediately to a user’s speech for more fluid experiences by recognizing defined words and phrases set by you. This is done transparently so that before the mic opens, Assistant will announce the mic will stay open temporarily so users know they can speak freely without waiting for additional prompts. For example, CoolGames is launching a game in a few weeks called, “Guess The Drawing” that uses Continuous Match Mode to allow the user to continuously guess what the drawing is until they get it right. The game is also built with Interactive Canvas for a more visual and immersive experience on smart displays.

Bringing AMP to smart displays

In addition to making it easy for you to build new experiences for Google Assistant, we also want to bring the depth of great web content together with the simple and robust AMP framework to deliver new experiences on Smart Displays. AMP allows you to create compelling, smooth websites that have a great user experience. AMP compliant articles are coming to smart displays later this summer with News. Stay tuned for more updates in the coming months as we expand to enable more web content categories for Smart Displays.

With these tools, we want to empower developers to build helpful experiences of the future with Google Assistant, enabling people to get what they need more simply, while giving them time back to focus on what matters most.

Announcing Actions Builder & Actions SDK: New tools optimized for the Google Assistant

Posted by the Assistant Developer Platform team

Since the launch of the Google Assistant, our developer ecosystem has been instrumental in delivering compelling voice experiences to more than 500 million active users. Today, we’re taking a major step forward in helping you build these custom voice apps and services by introducing a suite of new and improved developer tools: Actions Builder and Actions SDK. These tools make building Conversational Actions for the Assistant easier and more streamlined than ever.

Better design and development tools

Actions Builder is a web-based IDE that lets you develop, test, and deploy directly in the Actions console. The graphical interface lets you visualize the conversational flow, manage Natural Language Understanding (NLU) training data, and debug with advanced tools.

For those of you who prefer local IDEs, the updated Actions SDK provides a file based representation of your Actions project. This lets you author NLU training data and conversational flows locally as well as bulk import and export training data. We've also updated the CLI that accompanies Actions SDK, so you can build and manage Actions projects completely with code, using your favorite source control and continuous integration tools.

Together, Actions Builder and Actions SDK create a seamless, consolidated development experience. No matter what tool you start with, you can switch between them based on what works best for your workflow. For example, you can use Actions Builder to lay out conversational flows and provide NLU training data, Actions SDK to write fulfillment code, and the CLI to synchronize the two. These tools create an environment where all team members can contribute effectively and focus on what they do best: design and code.

New interaction model

A new, powerful interaction model lets you design conversations quickly and efficiently. Intents and scenes let you define robust NLU training data and behavior for specific conversational contexts. Using scenes as building blocks, you define active intents, declare context specific error handling, collect data through slot filling, and respond with prompts.

Scenes also separate conversational flow definitions from fulfillment logic, so you can reuse the same flows across multiple conversations. Transitions between scenes let you define when one conversational context switches to another. All your scenes and transitions describe a full conversational flow and all possible dialog turns.

You can express the entire interaction model with either the Actions Builder or Actions SDK. A typical way to develop is to use Actions Builder to view and edit your scenes and then use Actions SDK to sync changes to your local file system. This lets you version control your project, modify your project files, and build fulfillment in your favorite development environment.

Faster and smarter runtime engine

Under the hood, we also made a lot of improvements that your users will appreciate. We sped up the Assistant runtime engine, so users get faster responses and a smoother experience. We’ve also made the runtime engine smarter, so your Actions can understand users better with the same amount of training data.

Production ready platform

We've worked with Pretzel Labs and Galinha Pintadinha to test the capabilities of the new platform and to refine the interaction model and runtime engine improvements.

Pretzel Labs built Kids Court with Actions Builder, creating a full conversational flow with no code and added fulfilment for advanced functionality.

"Having the combination of a visual layout with webhook blocks for code helps us collaborate clearly and more efficiently. Something I liked very much about this was the separation between the designer and the developers' parts, making it very intuitive to make design changes without affecting backend logic."
-- Adva Levin, founder of Pretzel Labs

Galinha Pintadinha runs one of the biggest YouTube channels and built one the most popular Conversational Actions in their country. Their development team migrated to the new platform to optimize their workflow and simplify future Action development. Galinha Pintadinha’s Actions now contain half the number of intents and have a radically simplified conversation tree. Using features like contextual error handling, they were able to improve the user experience and quality with little to no cost.

"Actions Builder is a robust and well designed toolbox for developing conversational apps. The concept of scenes and transitions helped us define the flow of our Action in a much more streamlined way."
-- Mário Neto, engineer at Galinha Pintadinha

Get started

To learn more about Actions Builder and SDK and to start developing your next Actions, check out our new developer resources. Our codelabs will walk you through using the new tooling and interaction model. Samples for all major features are also available, so you can start playing with code immediately. See the full set of documentation to start building today.

Stay tuned for more platform updates and happy coding!

Join 24 Hours of Google Cloud Talks by DevRel

Posted by Greg Wilson, Director of Cloud Developer Advocacy

Google Cloud is excited to announce a global, 24-hour event as part of our new Google Cloud Talks by DevRel Series. The event will begin on June 22 at 5:00 PM Pacific Time (June 23 at 10:00am UTC) and run through June 23 5:00 PM Pacific Time.

This 24-hour event will be a way for cloud developers, admins, operators, and analysts globally to participate in interactive sessions, panels, demos, and Q&As with Google Cloud Developer Relations and experts from the community.

We all miss gathering in person to learn, stay updated on new ideas, and connect, which is why no matter what time it is where you are, you can join and share this virtual experience with developers from around the world.

Organized into three regional segments, the event will include live streamed content with everything from Dialogflow and Cloud AI to serverless and Cloud Run. Check out the agenda and register here.

Unwrapping the Android 11 Beta, plus more developer updates

Posted by Stephanie Cuthbertson, Director, Product Management

Editor’s note: The global community of Android developers has always been a powerful force in shaping the direction of the Android platform; each and every voice matters to us. We have cancelled the virtual launch event to allow people to focus on important discussions around racial justice in the United States. Instead, we are releasing the Android 11 Beta today in a much different form, via short-form videos and web pages that you can consume at your own pace when the time is right for you. Millions of developers around the world build their business with Android, and we're releasing the Beta today to continue to support these developers with the latest tools. We humbly thank those who are able to offer their feedback on this release.

Today, we’re unwrapping the Beta release for Android 11 as well as the latest updates for developers from Kotlin coroutines, to progress on the Jetpack Compose toolkit, to faster builds in Android Studio, even a refreshed experience for the Play Console.

Android 11 Beta: now available

You’ve been helping us with feedback on the Android 11 developer previews since February, and today we released the first Beta of Android 11 focused on three key themes: People, Controls, and Privacy.

People: we’re making Android more people-centric and expressive, reimagining the way we have conversations on our phones, and building an OS that can recognize and prioritize the most important people in your life:

  • Conversation notifications appear in a dedicated section at the top of the shade, with a people-forward design and conversation specific actions, such as opening the conversation as a bubble, creating a conversation shortcut on the home screen, or setting a reminder.
  • Bubbles help users to keep conversations in view and accessible while multitasking. Messaging and chat apps should use the Bubbles API on notifications to enable this in Android 11.
  • Consolidated keyboard suggestions let Autofill apps and Input Method Editors (IMEs) securely offer context-specific entities and strings directly in an IME’s suggestion strip, where they are most convenient for users.
  • Voice Access, for people who control their phone entirely by voice, now includes an on-device visual cortex that understands screen content and context, and generates labels and access points for accessibility commands.
gif of people features such as prioritize messages across apps from the VIPs in your life

Controls: the latest release of Android can now help you can quickly get to all of your smart devices and control them in one space:

  • Device Controls make it faster and easier than ever for users to access and control their connected devices. Now, by simply long pressing the power button, they’re able to bring up device controls instantly, and in one place. Apps can use a new API to appear in the controls. More here.
  • Media Controls make it quick and convenient for users to switch the output device for their audio or video content, whether it be headphones, speakers or even their TV. You can enable this today from Developer Options, and it will be on by default in an upcoming Beta release. More here.
Controls gif including Smart home controls, payment methods and more, all in one place

Privacy: In Android 11, we’re giving users even more control over sensitive permissions and working to keep devices more secure through faster updates.

  • One-time permission lets users give an app access to the device microphone, camera, or location, just that one time. The app can request permissions again the next time the app is used. More here.
  • Permissions auto-reset: if users haven’t used an app for an extended period of time, Android 11 will “auto-reset” all of the runtime permissions associated with the app and notify the user. The app can request the permissions again the next time the app is used. More here.
  • Background location: In February, we announced developers will need to get approval to access background location in their app to prevent misuse. We're giving developers more time to make changes and won't be enforcing the policy for existing apps until 2021. More here.
  • Google Play System Updates, launched last year, lets us expedite updates of core OS components to devices in the Android ecosystem. In Android 11, we more than doubled the number of updatable modules, and those 12 new modules will help improve privacy, security, and consistency for users and developers.
Privacy gif including more ways to keep your data secure with one-time permissions and permissions auto-reset.

Developer friendliness: We want to make it easy for developers to take advantage of the new release, so to make compat testing easier, we’ve:

  • Gated most breaking changes until you target Android 11 (so they won’t take effect until you explicitly change your manifest)
  • Added new UI in developer options to let you toggle many of these changes for testing
  • added a new Platform Stability release milestone where all API and behavior changes will be complete, so you can finalize your app updates knowing the platform is stable.

Android 11 also includes a number of other developer productivity improvements like wireless ADB debugging, ADB incremental for faster installs of large APKs, and more nullability annotations on platform APIs (to catch issues at build time instead of runtime), and more.

The first Beta for Android 11 is available today, with final SDK and NDK APIs and new features to try in your apps. If you have a Pixel 2, 3, 3a, or 4 device, enroll here to get Android 11 Beta updates over-the-air. As always, downloads for Pixel and the Android Emulator are also available. To learn about all of the developer features in Android 11, visit the Android 11 developer site.

Modern Android development

Over the past several years, the Android team has been hard at work improving the mobile developer experience, to make you more productive. This includes the Android Studio IDE, a great language (Kotlin!), Jetpack libraries to make common tasks easy, and Android App Bundles to improve app distribution. Today we call this modern Android development - bringing you the best of Android to make you as efficient and productive as possible.

Modern android development showcasing new logos gif

Android Studio

Today, we released new features in Android Studio 4.1 Beta and 4.2 Canary, focused on a number of crucial asks from developers:

  • Debugging is simpler with wireless debugging over ADB with Android 11 devices. We also added the Database Inspector and Dependency Injection (Dagger) tools;
  • Device testing is better, with the Android Emulator now hosted directly inside the IDE. Tests now run side-by-side so you can see results from multiple devices at the same time. And we’ve improved the device manager to more easily handle your devices.
  • Machine learning is easier -- you can now import your models for ML Kit and TensorFlow Lite directly in the IDE.
  • Build and deployment are faster thanks to Kotlin Symbol Processing, caching of the task graph in Gradle, and faster app deployment to all devices on Android 11. And the new build analyzer can help you diagnose where your build may have bottlenecks.
  • Games tooling is more powerful with an updated performance profiler UI, an overhauled System Trace tool, and support for native memory profiling.
Android Studio - New Features, 4.1 Beta & 4.2 Canary

Try out the latest: Android Studio 4.1 Beta and Android Studio 4.2 Canary.

Kotlin and Jetpack

Languages and libraries are a major area of investment in modern Android development, with Kotlin’s modern, concise language and Jetpack’s opinionated powerful libraries all focused around making you more productive.

With the rise in Kotlin adoption (with over 70% of top 1000 apps on Google Play now using Kotlin) and so many developers using Kotlin, we can now use it to simplify your experience in new ways. Kotlin coroutines are a language feature of Kotlin which make concurrent calls much easier to write and understand. We’re making coroutines our official recommendation, and we’ve built coroutines support into 3 of the most-used Jetpack libraries -- Lifecycle, WorkManager, and Room -- so you can write even better code.

Kotlin itself also continues to get better with every release, thanks to the awesome team at Jetbrains. Kotlin 1.4 provides faster code completion, more powerful type inference enabled by default, function interfaces, as well as helpful quality of life improvements like mixing named and positioning arguments.

We also continue to push Jetpack forward - a suite of libraries which spans multiple Android releases and is designed to make common mobile development patterns fast and easy. Many of us have long loved Dagger, so we worked with the Dagger team to bring you Hilt, a developer-friendly wrapper on top of Dagger, as a recommended Dependency Injection solution for Android. You’ll find this in alpha ready to try out. We’ve also added a second new library App Startup, to help both app developers and library developers improve app startup time by optimizing initialization of libraries. We have many more updates to existing libraries as well, including a major update to Paging 3, rewritten Kotlin-first with full support for coroutines!

The latest on our new UI toolkit, Compose

There’s one more thing you need to be super productive — and that’s a powerful UI toolkit to quickly and easily build beautiful UIs on Android, with native access to the platform APIs. That’s why we’re building Jetpack Compose, our new modern UI toolkit that brings your app to life with less code, powerful tools, and intuitive Kotlin APIs.

Today we are launching Jetpack Compose Developer Preview 2, packed with features developers have been asking us for:

  • Interoperability with Views (start mixing Composable functions in your existing app) (new!)
  • Animations (new!)
  • Testing (new!)
  • Constraint Layout (new!)
  • Adapter list (new!)
  • Material UI components
  • Text and editable Text (new!)
  • Theming and Graphics
  • Window management
  • Input and Gestures

We've also added a number of new capabilities to Android Studio 4.2, in close partnership with Jetbrains Kotlin team, to help you build apps with Compose:

  • Kotlin compiler plugin for code generation
  • Compose Preview Annotations
  • Real-time interactive Compose previews
  • Deploy individual composables to device
  • Compose Code completion
  • Sample Data API for Compose

Compose isn’t ready for production use yet, in particular as we finish performance optimizations, but we’d love you to give it a try and share feedback. We plan to launch Alpha this summer and 1.0 next year.

An all-new Google Play Console

Google Play is focused on helping developers grow their business. With that mission in mind, we've redesigned the Google Play Console to help you maximize your success on our platform. In addition to being clearer and easier to use, we've added features to help you:

  • Find, discover, and understand features to help you thrive on Google Play
  • Find new guidance on policy changes, release status, and user feedback
  • Better understand performance insights with new acquisition reports
  • Enable everyone on your team to use Play Console features with new user management options

Learn more about the new Google Play Console in this post or join the beta now at play.google.com/console. Your feedback helps us continue to improve Google Play Console for everyone, so please let us know what you think.

Wrapping it all up

But there’s so much more we’re launching that we didn’t get to talk about!

  • We have 12 talks we just posted right on the Android Developers YouTube channel.
  • We’re launching 11 Weeks of Android to keep the conversation going, with new developer content each week on topics you’ve asked for, like UI, Jetpack and Machine Learning. Check out the schedule here to learn more.
  • We’re introducing a global series of online community meetups to discuss what’s new in Android 11, how to make your app compatible, and the essentials and best practices of modern Android development. Find an Android 11 Meetup near you.

3 ways local developer communities are staying connected virtually

Posted by JP Loughran, Google Developers

As the world continues to embrace remote opportunities, Google Developer Group (GDG) and Developer Student Club (DSC) communities have been working hard to support each other virtually – complete with online technical education and remote spaces to build local community connections. In particular, community groups in Sweden, Singapore, and throughout MENA have been creating resources to help developers find online employment, education, and engagement opportunities. Curious to find out more? Keep reading below.

1. Employment - Sweden

Community members from Google Developer Group West Sweden recently rolled up their sleeves to do what they do best: hack. From April 6th – 8th, the community worked with the Swedish Government to create “Hack the Crisis,” a virtual community event focused on designing, testing, and executing ideas in response to recent challenges.

The event included several project pitches and a group of judges to select winning proposals. One of the finalists, Remote + Gigs on Platsbanken, developed a plan to modernize the Swedish Government’s employment website in an effort to save business.

Specifically, the idea suggests updating the website’s interface so that job seekers can be easily matched with compatible remote work based on their preferences. A creative way to safely bring work to both people and businesses in need.

2. Education - Singapore

(On the left is the Singapore University of Technology and Design. On the right is a virtual model of the campus.)

Recently, a Google Developer Student Club at the Singapore University of Technology and Design (SUTD) built a virtual model of their college to host tours that were canceled in person. Specifically, the team of 40+ student developers came together to construct the model on Minecraft, creating an experience that allows visitors to freely and interactively explore the campus – just like they would in person.

The team also used their knowledge of DialogFlow to build a tour guide chatbot that answers questions from the virtual visitors.

The university has loved the virtual campus. On the first day it opened, roughly 200 visitors joined tours and over 1,000 users came to interact with the site.

3. Engagement - Middle East & North Africa

Recently, 200+ developer communities, 100 local experts, and 10+ Google Developer Experts have come together to host MENA Digital Days – a 32 week series of live video workshops providing various training on everything from working from home to leadership to coding.

The series, which started at the end of March and will continue until the end of October, engages viewers with its live workshop style format and is published on a daily and weekly basis. With a unique theme each week, the series aims to provide learning opportunities for developers, women, students, and startups.

With such a broad range of participants from all over the world, MENA Digital Days is currently taking place in three languages: Arabic, French, and English. Catch up any time on past videos on the YouTube playlist or join a live workshop to get involved.

Community matters more than ever, so it’s impressive to see so many groups adapt so quickly to being digital-first. If you’re inspired by these stories, learn more about local developer communities hosting virtual events near you here.

Sip a cup of Java 11 for your Cloud Functions

Posted by Guillaume Laforge, Developer Advocate for Google Cloud

With the beta of the new Java 11 runtime for Google Cloud Functions, Java developers can now write their functions using the Java programming language (a language often used in enterprises) in addition to Node.js, Go, or Python. Cloud Functions allow you to run bits of code locally or in the cloud, without provisioning or managing servers: Deploy your code, and let the platform handle scaling up and down for you. Just focus on your code: handle incoming HTTP requests or respond to some cloud events, like messages coming from Cloud Pub/Sub or new files uploaded in Cloud Storage buckets.

In this article, let’s focus on what functions look like, how you can write portable functions, how to run and debug them locally or deploy them in the cloud or on-premises, thanks to the Functions Framework, an open source library that runs your functions. But you will also learn about third-party frameworks that you might be familiar with, that also let you create functions using common programming paradigms.

The shape of your functions

There are two types of functions: HTTP functions, and background functions. HTTP functions respond to incoming HTTP requests, whereas background functions react to cloud-related events.

The Java Functions Framework provides an API that you can use to author your functions, as well as an invoker which can be called to run your functions locally on your machine, or anywhere with a Java 11 environment.

To get started with this API, you will need to add a dependency in your build files. If you use Maven, add the following dependency tag in pom.xml:

<dependency>
<groupId>com.google.cloud.functions</groupId>
<artifactId>functions-framework-api</artifactId>
<version>1.0.1</version>
<scope>provided</scope>
</dependency>

If you are using Gradle, add this dependency declaration in build.gradle:

compileOnly("com.google.cloud.functions:functions-framework-api")

Responding to HTTP requests

A Java function that receives an incoming HTTP request implements the HttpFunction interface:

import com.google.cloud.functions.*;
import java.io.*;

public class Example implements HttpFunction {
@Override
public void service(HttpRequest request, HttpResponse response)
throws IOException {
var writer = response.getWriter();
writer.write("Hello developers!");
}
}

The service() method provides an HttpRequest and an HttpResponse object. From the request, you can get information about the HTTP headers, the payload body, or the request parameters. It’s also possible to handle multipart requests. With the response, you can set a status code or headers, define a body payload and a content-type.

Responding to cloud events

Background functions respond to events coming from the cloud, like new Pub/Sub messages, Cloud Storage file updates, or new or updated data in Cloud Firestore. There are actually two ways to implement such functions, either by dealing with the JSON payloads representing those events, or by taking advantage of object marshalling thanks to the Gson library, which takes care of the parsing transparently for the developer.

With a RawBackgroundFunction, the responsibility is on you to handle the incoming cloud event JSON-encoded payload. You receive a JSON string, so you are free to parse it however you like, with your JSON parser of your choice:

import com.google.cloud.functions.Context;
import com.google.cloud.functions.RawBackgroundFunction;

public class RawFunction implements RawBackgroundFunction {
@Override
public void accept(String json, Context context) {
...
}
}

But you also have the option to write a BackgroundFunction which uses Gson for unmarshalling a JSON representation into a Java class (a POJO, Plain-Old-Java-Object) representing that payload. To that end, you have to provide the POJO as a generic argument:

import com.google.cloud.functions.Context;
import com.google.cloud.functions.BackgroundFunction;

public class PubSubFunction implements BackgroundFunction<PubSubMsg> {
@Override
public void accept(PubSubMsg msg, Context context) {
System.out.println("Received message ID: " + msg.messageId);
}
}

public class PubSubMsg {
String data;
Map<String, String> attributes;
String messageId;
String publishTime;
}

The Context parameter contains various metadata fields like timestamps, the type of events, and other attributes.

Which type of background function should you use? It depends on the control you need to have on the incoming payload, or if the Gson unmarshalling doesn’t fully fit your needs. But having the unmarshalling covered by the framework definitely streamlines the writing of your function.

Running your function locally

Coding is always great, but seeing your code actually running is even more rewarding. The Functions Framework comes with the API we used above, but also with an invoker tool that you can use to run functions locally. For improving developer productivity, having a direct and local feedback loop on your own computer makes it much more comfortable than deploying in the cloud for each change you make to your code.

With Maven

If you’re building your functions with Maven, you can install the Function Maven plugin in your pom.xml:

<plugin>
<groupId>com.google.cloud.functions</groupId>
<artifactId>function-maven-plugin</artifactId>
<version>0.9.2</version>
<configuration>
<functionTarget>com.example.Example</functionTarget>
</configuration>
</plugin>

On the command-line, you can then run:

$ mvn function:run

You can pass extra parameters like --target to define a different function to run (in case your project contains several functions), --port to specify the port to listen to, or --classpath to explicitly set the classpath needed by the function to run. These are the parameters of the underlying Invoker class. However, to set these parameters via the Maven plugin, you’ll have to pass properties with -Drun.functionTarget=com.example.Example and -Drun.port.

With Gradle

With Gradle, there is no dedicated plugin, but it’s easy to configure build.gradle to let you run functions.

First, define a dedicated configuration for the invoker:

configurations { 
invoker
}

In the dependencies, add the Invoker library:

dependencies {
invoker 'com.google.cloud.functions.invoker:java-function-invoker:1.0.0-beta1'
}

And then, create a new task to run the Invoker:

tasks.register("runFunction", JavaExec) {
main = 'com.google.cloud.functions.invoker.runner.Invoker'
classpath(configurations.invoker)
inputs.files(configurations.runtimeClasspath,
sourceSets.main.output)
args('--target',
project.findProperty('runFunction.target') ?:
'com.example.Example',
'--port',
project.findProperty('runFunction.port') ?: 8080
)
doFirst {
args('--classpath', files(configurations.runtimeClasspath,
sourceSets.main.output).asPath)
}
}

By default, the above launches the function com.example.Example on port 8080, but you can override those on the command-line, when running gradle or the gradle wrapper:

$ gradle runFunction -PrunFunction.target=com.example.HelloWorld \
-PrunFunction.port=8080

Running elsewhere, making your functions portable

What’s interesting about the Functions Framework is that you are not tied to the Cloud Functions platform for deploying your functions. As long as, in your target environment, you can run your functions with the Invoker class, you can run your functions on Cloud Run, on Google Kubernetes Engine, on Knative environments, on other clouds when you can run Java, or more generally on any servers on-premises. It makes your functions highly portable between environments. But let’s have a closer look at deployment now.

Deploying your functions

You can deploy functions with the Maven plugin as well, with various parameters to tweak for defining regions, memory size, etc. But here, we’ll focus on using the cloud SDK, with its gcloud command-line, to deploy our functions.

For example, to deploy an HTTP function, you would type:

$ gcloud functions deploy exampleFn \
--region europe-west1 \
--trigger-http \
--allow-unauthenticated \
--runtime java11 \
--entry-point com.example.Example \
--memory 512MB

For a background function that would be notified of new messages on a Pub/Sub topic, you would launch:

$ gcloud functions deploy exampleFn \
--region europe-west1 \
--trigger-topic msg-topic \
--runtime java11 \
--entry-point com.example.PubSubFunction \
--memory 512MB

Note that deployments come in two flavors as well, although the above commands are the same: functions are deployed from source with a pom.xml and built in Google Cloud, but when using a build tool other than Maven, you can also use the same command to deploy a pre-compiled JAR that contains your function implementation. Of course, you’ll have to create that JAR first.

What about other languages and frameworks?

So far, we looked at Java and the plain Functions Framework, but you can definitely use alternative JVM languages such as Apache Groovy, Kotlin, or Scala, and third-party frameworks that integrate with Cloud Functions like Micronaut and Spring Boot!

Pretty Groovy functions

Without covering all those combinations, let’s have a look at two examples. What would an HTTP function look like in Groovy?

The first step will be to add Apache Groovy as a dependency in your pom.xml:

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.4</version>
<type>pom</type>
</dependency>

You will also need the GMaven compiler plugin to compile the Groovy code:

<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>compile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>

When writing the function code, just use Groovy instead of Java:

import com.google.cloud.functions.*

class HelloWorldFunction implements HttpFunction {
void service(HttpRequest request, HttpResponse response) {
response.writer.write "Hello Groovy World!"
}
}

The same explanations regarding running your function locally or deploying it still applies: the Java platform is pretty open to alternative languages too! And the Cloud Functions builder will happily build your Groovy code in the cloud, since Maven lets you compile this code thanks to the Groovy library.

Micronaut functions

Third-party frameworks also offer a dedicated Cloud Functions integration. Let’s have a look at Micronaut.

Micronaut is a “modern, JVM-based, full-stack framework for building modular, easily testable microservice and serverless applications”, as explained on its website. It supports the notion of serverless functions, web apps and microservices, and has a dedicated integration for Google Cloud Functions.

In addition to being a very efficient framework with super fast startup times (which is important, to avoid long cold starts on serverless services), what’s interesting about using Micronaut is that you can use Micronaut’s own programming model, including Dependency Injection, annotation-driven bean declaration, etc.

For HTTP functions, you can use the framework’s own @Controller / @Get annotations, instead of the Functions Framework’s own interfaces. So for example, a Micronaut HTTP function would look like:

import io.micronaut.http.annotation.*;

@Controller("/hello")
public class HelloController {

@Get(uri="/", produces="text/plain")
public String index() {
return "Example Response";
}
}

This is the standard way in Micronaut to define a Web microservice, but it transparently builds upon the Functions Framework to run this service as a Cloud Function. Furthermore, this programming model offered by Micronaut is portable across other environments, since Micronaut runs in many different contexts.

Last but not least, if you are using the Micronaut Launch project (hosted on Cloud Run) which allows you to scaffold new projects easily (from the command-line or from a nice UI), you can opt for adding the google-cloud-function support module, and even choose your favorite language, build tool, or testing framework:

Micronaut Launch

Be sure to check out the documentation for the Micronaut Cloud Functions support, and Spring Cloud Function support.

What’s next?

Now it’s your turn to try Cloud Functions for Java 11 today, with your favorite JVM language or third-party frameworks. Read the getting started guide, and try this for free with Google Cloud Platform free trial. Explore Cloud Functions’ features and use cases, take a look at the quickstarts, perhaps even contribute to the open source Functions Framework. And we’re looking forward to seeing what functions you’re going to build on this platform!