This guide explains how to start development with Google Fit on Android.
Setup
Before you start to build your app, complete the steps in the following sections.
Get a Google Account
To use the Google Fit APIs, you need a Google Account. You can create a new account or
use an existing account.
Get Google Play services
Get the latest client library for Google Play services on your development host:
- Open the Android SDK Manager.
- Under SDK Tools, find Google Play services.
- If the status for these packages isn't Installed, select them both and click Install Packages.
Get an OAuth 2.0 client ID
To enable the Fitness API, get an OAuth 2.0 client ID.
Create and configure your project
We recommend using the Android Studio development environment to build an app with the Fitness API. For details on how to make a new project and configure it in Android Studio, see Create a project.
Add the Google Play services client library
In Android Studio, open the build.gradle
file for your module and add the Google Play services client library as a dependency:
plugin { id("com.android.application") } ... dependencies { implementation("com.google.android.gms:play-services-fitness:21.2.0") implementation("com.google.android.gms:play-services-auth:21.3.0") }
apply plugin: 'com.android.application' ... dependencies { implementation 'com.google.android.gms:play-services-fitness:21.2.0' implementation 'com.google.android.gms:play-services-auth:21.3.0' }
This makes sure that Gradle automatically downloads the fitness SDK when it builds your app.
Build and test your app
After you finish the setup steps, you can start to build your app. To get started, learn about the types of data your app can store and read. Learn more about working with data in Google Fit.
Get the necessary Android permissions
To read and write some types of data, your app needs to request Android permissions.
Get OAuth permissions
The data types that your app has permission to access correspond to
authorization scopes. To ask
for these permissions, you need to add
which data types your app needs access to in a FitnessOptions
instance. When your app asks to use any of the Google Fit data
types, the Android SDK automatically checks which scopes they belong to and asks
the user for authorization to those scopes.
Create an API client
Create an API client and add the data types that your app needs to access to write or read data. The following endpoints are available:
-
SensorsClient
: Access different sources of health and wellness data from hardware sensors in the local device and in companion devices. -
RecordingClient
: For low-power, always-on background collection of sensor data. -
HistoryClient
: Insert, delete, and read historical data in Google Fit. -
SessionsClient
: Create and manage Sessions of user activity. -
GoalsClient
: Read Heart Point and Steps goals created by users in Google Fit. -
ConfigClient
: Access custom data types and settings in the Google Fit platform.
Resulting user authorization flow
The following shows the resulting authorization flow that users experience when they're asked for permissions:

- Android permissions: Users see what Android permissions your app has requested before downloading it. After your app is downloaded, it requests any runtime permissions that it needs, and users grant or deny these permissions.
- Check and connect: Your app checks whether permissions were granted before it requests access to other data types.
- OAuth scopes request: Google prompts the user to grant your app the OAuth scopes needed for the data types that it wants to access.
- Access applied: After the user grants permissions, your app can access the data types that belong to the scopes that the user has granted permission for.
Apply for verification
After you build and test your app, you need to apply for verification with different levels of justification needed for sensitive and restricted scopes.