A simple example of how to record steps and read them back.
- Android API Level >= 14
- Android Build Tools v29
- Android Support Repository
- Register a Google Project with an Android client per getting started instructions http://developers.google.com/fit/android/get-started
This sample uses the Gradle build system. To build this project, use the "gradlew build" command or use "Import Project" in Android Studio.
NOTE: You must register an Android client underneath a Google Project in order for the Google Fit API to become available for your app. The process ensures your app has proper consent screen information for users to accept, among other things required to access Google APIs. See the instructions for more details: http://developers.google.com/fit/android/get-started
The most common problem using these samples is a SIGN_IN_FAILED exception. Users can experience this after selecting a Google Account to connect to the Fit API. Errors will be visible in logcat.
If you encounter this error, check the following steps:
- Follow the instructions at http://developers.google.com/fit/android/get-started for registering an Android client.
- Ensure that the Fit API is enabled for your Cloud project.
- Check your credentials for your Cloud project:
- Ensure that your package name for your credentials matches the sample.
- Ensure the package name matches the
applicationId
in theapp/build.gradle
file. - Ensure the Signing-certificate fingerprint is entered correctly.
Use the following channels for support:
- Stack Overflow: http://stackoverflow.com/questions/tagged/android
If you've found an error in this sample, please file an issue: https://github.com/android/fit
Patches are encouraged, and may be submitted according to the instructions in CONTRIB.md.