Home > Mobile >  Problems with building expo react native app for android because of expo-notifications
Problems with building expo react native app for android because of expo-notifications

Time:12-02

When I try to build my expo react-native app for Android, there's a problem with it because of expo-notifications(however, iOS build succeeds). The task of compiling this library fails with such output:


> Task :expo-notifications:compileReleaseKotlin FAILED
[stderr] e: /home/expo/workingdir/build/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt: (418, 74): Unresolved reference: S
[stderr] e: /home/expo/workingdir/build/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt: (418, 91): Unresolved reference: FLAG_MUTABLE
[stderr] e: /home/expo/workingdir/build/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt: (454, 74): Unresolved reference: S
[stderr] e: /home/expo/workingdir/build/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/NotificationsService.kt: (454, 91): Unresolved reference: FLAG_MUTABLE
[stderr] e: /home/expo/workingdir/build/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/ExpoSchedulingDelegate.kt: (101, 53): Unresolved reference: S
[stderr] e: /home/expo/workingdir/build/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/service/delegates/ExpoSchedulingDelegate.kt: (101, 71): Unresolved reference: canScheduleExactAlarms
> Task :react-native-gesture-handler:compileReleaseKotlin
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt: (30, 17): 'constructor Handler()' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt: (676, 11): Name shadowed: size
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt: (44, 17): 'constructor Handler()' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt: (73, 17): 'constructor Handler()' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt: (82, 17): 'constructor Handler()' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (439, 30): 'RNGestureHandlerEnabledRootView' is deprecated. Use <GestureHandlerRootView /> component instead. Check gesture handler installation instructions in documentation for more information.
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (454, 33): 'resolveRootTagFromReactTag(Int): Int' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (479, 19): 'RNGestureHandlerEnabledRootView' is deprecated. Use <GestureHandlerRootView /> component instead. Check gesture handler installation instructions in documentation for more information.
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (505, 33): 'resolveRootTagFromReactTag(Int): Int' is deprecated. Deprecated in Java
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt: (520, 67): Parameter 'motionEvent' is never used
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt: (80, 42): Parameter 'disallowIntercept' is never used
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt: (112, 28): Parameter 'viewTag' is never used
w: /home/expo/workingdir/build/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt: (54, 23): 'RNGestureHandlerEnabledRootView' is deprecated. Use <GestureHandlerRootView /> component instead. Check gesture handler installation instructions in documentation for more information.
> Task :app:bundleReleaseJsAndAssets
info Writing bundle output to:, /home/expo/workingdir/build/android/app/build/generated/assets/react/release/index.android.bundle
info Writing sourcemap output to:, /home/expo/workingdir/build/android/app/build/generated/sourcemaps/react/release/index.android.bundle.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 59 asset files
info Done copying assets
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
434 actionable tasks: 434 executed
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':expo-notifications:compileReleaseKotlin'.
[stderr] > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
[stderr]    > Compilation error. See log for more details
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 5m 9s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

I tried the solution proposed here to upgrade RN from 0.64.3 to 0.64.4 patched version, but it gave no effect. But after removing expo-notifications from package.json and commenting all places where I use notification, the build succeeded. So I guess it could be some issues with expo-notifications library, or version conflict, or something like that. Has anybody encountered such a problem? Thanks!

Versions of libraries

"react": "17.0.1",
"react-native": "0.64.4",
"expo": "^44.0.0",
"expo-notifications": "^0.15.2",

My eas.json

{
  "cli": {
    "version": ">= 2.6.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal"
    },
    "production": {
        "ios": {
            "image": "macos-monterey-12.4-xcode-13.4"
        },
        "android": {
            "image": "ubuntu-18.04-jdk-8-ndk-r19c"
        }
    }
  },
  "submit": {
    "production": {
        "ios": {
            "appleId": "*****",
            "ascAppId": "*****",
            "appleTeamId": "*****"
        }
    }
  }
}

CodePudding user response:

I found how to fix this, you have to run this commands

expo doctor
expo doctor --fix-dependencies

After these commands it builds successfully

  • Related