React-native-notifications: Android can not get V3 to work - cannot resolve symbol wix

Created on 17 Jan 2020  路  13Comments  路  Source: wix/react-native-notifications

I am using RN 0.61.2 and V3.0.0 and can not get it to build correctly. In main application i keep geting cannot resolve symbol wix for import, and of course i am getting below cannot resolve symbol RNNotificationsPackage. I followed guide under android installation.
Should this package link automatically or should i link it manually?
I tried solution from https://github.com/wix/react-native-notifications/issues/396 but it did not work for me.

馃彋 stale

Most helpful comment

@pani7 I believe #396 is for people running V2s. I managed to get V3 build on mine. I'm running RN 61.5.

android/settings.gradle:

include ':react-native-notifications'
project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')

android/app/build.gradle:

defaultConfig {
    ...
    missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
}
dependencies {
    implementation project(':react-native-notifications');
}

react-native.config.js:

module.exports = {
  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null
      }
    }
  }
}

android/app/src/main/java/com/playmetricsmobile/MainApplication.java:

import com.wix.reactnativenotifications.RNNotificationsPackage;
......

protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();         
      packages.add(new RNNotificationsPackage(MainApplication.this));
      return packages;
    }

You might wanna clear the node_modules, watchman and yarn/npm cache before you do all this. I found clearing out the project and resync for Android sometimes work too.

All 13 comments

@pani7 I believe #396 is for people running V2s. I managed to get V3 build on mine. I'm running RN 61.5.

android/settings.gradle:

include ':react-native-notifications'
project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')

android/app/build.gradle:

defaultConfig {
    ...
    missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
}
dependencies {
    implementation project(':react-native-notifications');
}

react-native.config.js:

module.exports = {
  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null
      }
    }
  }
}

android/app/src/main/java/com/playmetricsmobile/MainApplication.java:

import com.wix.reactnativenotifications.RNNotificationsPackage;
......

protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();         
      packages.add(new RNNotificationsPackage(MainApplication.this));
      return packages;
    }

You might wanna clear the node_modules, watchman and yarn/npm cache before you do all this. I found clearing out the project and resync for Android sometimes work too.

Beautiful, this sync project with gradle files worked, or it was just the version 3.1.1 that made the difference. In any case thanks for your help

Worked for me too, thanks!
This should be added to the docs :/

@pani7 I believe #396 is for people running V2s. I managed to get V3 build on mine. I'm running RN 61.5.

android/build.gradle:

include ':react-native-notifications'
project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')

android/app/build.gradle:

defaultConfig {
    ...
    missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
}
dependencies {
    implementation project(':react-native-notifications');
}

react-native.config.js:

module.exports = {
  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null
      }
    }
  }
}

android/app/src/main/java/com/playmetricsmobile/MainApplication.java:

import com.wix.reactnativenotifications.RNNotificationsPackage;
......

protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();       
      packages.add(new RNNotificationsPackage(MainApplication.this));
      return packages;
    }

You might wanna clear the node_modules, watchman and yarn/npm cache before you do all this. I found clearing out the project and resync for Android sometimes work too.

great one ! work perfect.

Hey, does anyone know why for this part

include ':react-native-notifications'
project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')

i would be getting the following when trying to sync after adding to the top level gradle build?

CONFIGURE FAILED in 1s
Gradle DSL method not found: 'include()'

Edit: not sure why i was different but i had to add this into my settings.gradle to get it to build again

Hey, does anyone know why for this part

include ':react-native-notifications'
project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')

i would be getting the following when trying to sync after adding to the top level gradle build?

CONFIGURE FAILED in 1s
Gradle DSL method not found: 'include()'

Edit: not sure why i was different but i had to add this into my settings.gradle to get it to build again

Have you tried clear out the .idea and .gradle folder? Close Android Studio, remove those folders and open Android Studio to resync, most of my gradle issues were fixed this way, I've never seen that error before but hopefully this would fix it.

@DevArenaCN did you make a mistake in your instructions above?
This part should go to settings.gradle not app build.gradle as you wrote, right?

include ':react-native-notifications' project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')

Also do i need to follow the instructions on firebase link - how to edit manifest and add
implementation 'com.google.firebase:firebase-messaging:20.1.0'
into app/gradle? Or the steps in react-native-notifications instructions are enough?

@DevArenaCN did you make a mistake in your instructions above?
This part should go to settings.gradle not app build.gradle as you wrote, right?

include ':react-native-notifications' project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app')

Yes that was a typo, just updated that.

Also do i need to follow the instructions on firebase link - how to edit manifest and add
implementation 'com.google.firebase:firebase-messaging:20.1.0'
into app/gradle? Or the steps in react-native-notifications instructions are enough?

did you follow those steps or it works fine without it

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

The issue has been closed for inactivity.

facing the same problem here
tried lots of solutions

Was this page helpful?
0 / 5 - 0 ratings