question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request to support androidx library

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
quarrymancommented, Sep 11, 2019

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

2reactions
asifalikhokharcommented, Jun 20, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support Library Setup - Android Developers
The AndroidX library contains the existing support library and also includes the latest Jetpack components. You can continue to use the support library....
Read more >
Can I use library that used android support with Androidx ...
In the project folder, in build.gradle(Module:Application). Fix compileSdkVersion to 28 ...
Read more >
Migrate an existing project to AndroidX from support libraries
Migrate an existing project to AndroidX from support libraries ... AndroidX is an open-source project by Google which provides a major improvement ...
Read more >
Android Support Library - Tutorial - Vogella.com
The AndroidX library package is a set of code libraries that provide backward-compatible enhancements of the Android framework.
Read more >
Difference Between AndroidX and Android Support Libraries
Dependencies that are required to add in order to use an android component in the application include various other things that are of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found