react-native-google-fit: Build failed with an exception: cannot find symbol getName()

Build failed on new RN project

/node_modules/react-native-google-fit/android/src/main/java/com/reactnative/googlefit/StepHistory.java:211: error: cannot find symbol
            if (dataSource.getName() != null) {
                          ^
  symbol:   method getName()
  location: variable dataSource of type DataSource
/node_modules/react-native-google-fit/android/src/main/java/com/reactnative/googlefit/StepHistory.java:212: error: cannot find symbol
                source.putString("name", dataSource.getName());
                                                   ^
  symbol:   method getName()
  location: variable dataSource of type DataSource
/node_modules/react-native-google-fit/android/src/main/java/com/reactnative/googlefit/RecordingApi.java:56: error: cannot find symbol
                return DataType.TYPE_ACTIVITY_SAMPLES;
                               ^
  symbol:   variable TYPE_ACTIVITY_SAMPLES
  location: class DataType

to fix that you need explicitly set rootProject.ext.set("fitnessVersion", "18.0.0") in your build.gradle config, there is breaking changes in v19

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 16
  • Comments: 20

Most upvoted comments

works! in android/app/build.gradle

Screenshot 2020-08-11 at 10 32 10

or, you can put in your root gradle file at app-name/android/build.gradle:

buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 19
        compileSdkVersion = 29
        targetSdkVersion = 29
        supportLibVersion = "28.0.0"

        // react-native-google-fit
        fitnessVersion = "18.0.0"
    }
    repositories {
    ...

Thanks this just started happening when a build was fine on Friday.

As @HumbleBeck says, put it in node-modules/react-native-google-fit/android/build-gradle

def safeExtGet(prop, fallback) { rootProject.ext.set("fitnessVersion", "18.0.0") }

@mkwforaus do you try to clean cache and rebuild/reinstall your project? any sign out or sign in mechanism? Note that version 10 use deprecated api to fetch data, v13 uses the standard one.

This is due to a recent release of Google play fitness service: https://developers.google.com/android/guides/releases#august_10_2020

@agnieszkabugla fix is working for me, but I think that this library shouldn’t use the most recent version of Google services, but a fixed version

We were actually using an old version of the node module which was not taking the dependency version from the rootProject. We have upgraded the version to 0.13.0 and then tried to set the version of fitnessVersion to 18.0.0 as mentioned by @HumbleBeck and it works fine. Thanks a lot everyone 😃