react-native-device-info: Android build errors with 0.22.1 around getLocales()

Summary

I recently just upped my version of this library to 0.22.1 from 0.21.5 and everything is working locally for me. But when I run my build in Travis CI the build is failing with these errors.

Travis CI Java: Switching to Oracle JDK8 (java-8-oracle), JAVA_HOME will be set to /usr/lib/jvm/java-8-oracle

/home/travis/build/<user>/<appname>/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:71: error: cannot find symbol
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                                                    ^
  symbol:   variable N
  location: class VERSION_CODES
/home/travis/build/<user>/<appname>/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:72: error: cannot find symbol
      current = getReactApplicationContext().getResources().getConfiguration().getLocales().get(0);
                                                                              ^
  symbol:   method getLocales()
  location: class Configuration
/home/travis/build/<user>/<appname>/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:92: error: cannot find symbol
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                                                    ^
  symbol:   variable N
  location: class VERSION_CODES
/home/travis/build/<user>/<appname>/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:93: error: cannot find symbol
      current = getReactApplicationContext().getResources().getConfiguration().getLocales().get(0);
                                                                              ^
  symbol:   method getLocales()
  location: class Configuration
Note: /home/travis/build/<user>/<appname>/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
4 errors
:react-native-device-info:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-device-info:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Version 0.22.1
Affected OS Android
OS Version SDK 26

Current behavior

Builds fails on gradle command

/home/travis/build/<user>/<appname>/android/gradlew assembledevRelease -p ./android -DENVFILE=.env --no-daemon --max-workers 2

Expected behavior

Expecting the build to be successful.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 23 (3 by maintainers)

Most upvoted comments

@reedyrm @maksim-harakhovich-itechart @kingmatusevich @tbenr @cusspvz

I made a pull request. https://github.com/rebeccahughes/react-native-device-info/pull/460 Could you check that this change resolves this issue?

You can install this by following in package.json

"react-native-device-info": "git+https://github.com/hayanmind/react-native-device-info.git#e1899138b95bc8f71aab1877c2c2627ecab5e1c4"