evollu / react-native-fcm

react native module for firebase cloud messaging and local notification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request to support androidx library

mkashlev opened this issue · comments

I have upgraded react native, react and all libraries to latest versions. All of them support androidx. However, your library is lagging behind.
Migrating to androidx removes the android.support dependency. This dependency and androidx conflict with each other and, frankly, share the same functionality. However, react-native-fcm depends on android.support.* dependencies.

When I try to compile code for android by running react-native run-android, which, in turn, runs gradle assemble, I get the following errors:

/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/MessagingService.java:8: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/InstanceIdService.java:7: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java:30: error: cannot find symbol
import android.support.v4.app.NotificationManagerCompat;
                             ^
  symbol:   class NotificationManagerCompat
  location: package android.support.v4.app
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java:31: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:19: error: cannot find symbol
import android.support.v4.app.NotificationCompat;
                             ^
  symbol:   class NotificationCompat
  location: package android.support.v4.app
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:20: error: cannot find symbol
import android.support.v4.app.NotificationManagerCompat;
                             ^
  symbol:   class NotificationManagerCompat
  location: package android.support.v4.app
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:21: error: package android.support.v4.content does not exist
import android.support.v4.content.LocalBroadcastManager;
                                 ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/MessagingService.java:45: error: cannot find symbol
                    LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                    ^
  symbol: variable LocalBroadcastManager
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/MessagingService.java:50: error: cannot find symbol
                            LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                            ^
  symbol: variable LocalBroadcastManager
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/InstanceIdService.java:48: error: cannot find symbol
                    LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                    ^
  symbol: variable LocalBroadcastManager
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/InstanceIdService.java:53: error: cannot find symbol
                            LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(message);
                            ^
  symbol: variable LocalBroadcastManager
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java:77: error: cannot find symbol
        if(NotificationManagerCompat.from(getReactApplicationContext()).areNotificationsEnabled()){
           ^
  symbol:   variable NotificationManagerCompat
  location: class FIRMessagingModule
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java:263: error: cannot find symbol
        LocalBroadcastManager.getInstance(getReactApplicationContext()).registerReceiver(new BroadcastReceiver() {
        ^
  symbol:   variable LocalBroadcastManager
  location: class FIRMessagingModule
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java:309: error: cannot find symbol
        LocalBroadcastManager.getInstance(getReactApplicationContext()).registerReceiver(new BroadcastReceiver() {
        ^
  symbol:   variable LocalBroadcastManager
  location: class FIRMessagingModule
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java:349: error: cannot find symbol
        LocalBroadcastManager.getInstance(getReactApplicationContext()).registerReceiver(new BroadcastReceiver() {
        ^
  symbol:   variable LocalBroadcastManager
  location: class FIRMessagingModule
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:81: error: package NotificationCompat does not exist
            NotificationCompat.Builder notification = new NotificationCompat.Builder(mContext, bundle.getString("channel"))
                              ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:85: error: cannot find symbol
                    .setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
                                   ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:81: error: package NotificationCompat does not exist
            NotificationCompat.Builder notification = new NotificationCompat.Builder(mContext, bundle.getString("channel"))
                                                                            ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:101: error: cannot find symbol
                        notification.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
                                                           ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:104: error: cannot find symbol
                        notification.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
                                                           ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:107: error: cannot find symbol
                        notification.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL);
                                                           ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:126: error: cannot find symbol
                    notification.setPriority(NotificationCompat.PRIORITY_MIN);
                                             ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:129: error: cannot find symbol
                    notification.setPriority(NotificationCompat.PRIORITY_HIGH);
                                             ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:132: error: cannot find symbol
                    notification.setPriority(NotificationCompat.PRIORITY_MAX);
                                             ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:135: error: cannot find symbol
                    notification.setPriority(NotificationCompat.PRIORITY_DEFAULT);
                                             ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:168: error: package NotificationCompat does not exist
                notification.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText));
                                                            ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:175: error: package NotificationCompat does not exist
                NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle();
                                  ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:175: error: package NotificationCompat does not exist
                NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle();
                                                                                      ^
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:210: error: cannot find symbol
                notification.setCategory(NotificationCompat.CATEGORY_CALL);
                                         ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:230: error: cannot find symbol
                notification.setDefaults(NotificationCompat.DEFAULT_LIGHTS);
                                         ^
  symbol:   variable NotificationCompat
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:237: error: cannot find symbol
                LocalBroadcastManager.getInstance(mContext).sendBroadcast(i);
                ^
  symbol:   variable LocalBroadcastManager
  location: class SendNotificationTask
/Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java:281: error: cannot find symbol
                NotificationManagerCompat.from(mContext).notify(notificationID, info);
                ^
  symbol:   variable NotificationManagerCompat
  location: class SendNotificationTask
Note: /Users/dmitrykashlev/qventus/mobileapp/PrototypeResponseApp/node_modules/react-native-fcm/android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
32 errors


FAILURE: Build failed with an exception.

I had to manually fix by subbing the following with the following:
android.support.v4.content.LocalBroadcastManager -> androidx.localbroadcastmanager.content.LocalBroadcastManager
android.support.v4.app.NotificationManagerCompat -> androidx.core.app.NotificationManagerCompat
android.support.v4.app.NotificationCompat -> androidx.core.app.NotificationCompat

Environment info:

  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
      Memory: 3.09 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.11.0 - /usr/local/bin/node
      Yarn: 1.10.1 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 25, 26, 27, 28
        Build Tools: 27.0.3, 28.0.2, 28.0.3
        System Images: android-19 | ARM EABI v7a, android-22 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5014246
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.58.5 => 0.58.5 
    npmGlobalPackages:
      react-native-git-upgrade: 0.2.7

commented

@mkashlev You may want to check out react-native-firebase. I am currently migrating to that. There is an example in this repo showing the migration path.

any update on this issue ? I've been running into the same for a few days and didn't find any solution yet.

I've finally managed to build successfully by manually replacing all mentioned imports with their respective androidx imports ..
Here is the migration guide to androidx
https://developer.android.com/jetpack/androidx/migrate

one can use 'npx jetify' to migrate to androidX. It has rather good manual

Is there a solution for this without manually editing stuff in npm_modules?

commented

I don't think this library is supported anymore. You can do all of the same things with react-native-firebase