React-native-push-notification: Cannot find symbol new ReactNativePushNotificationPackage

Created on 27 Apr 2018  路  11Comments  路  Source: zo0r/react-native-push-notification

So I was just setting up the project but always have an error regarding the ReactNativePushNotificationPackage .

I am using:

"react-native-push-notification": "^3.0.2",
"react": "16.3.0-alpha.1",
"react-native": "0.54.2",

it says package com.dieam.reactnativepushnotification does not exist

thus resulting for : cannot find symbol
new ReactNativePushNotificationPackage(),

Here is the code:

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.reactnativedocumentpicker.ReactNativeDocumentPicker;
import org.wonday.pdf.RCTPdfView;
import com.arttitude360.reactnative.rngoogleplaces.RNGooglePlacesPackage;
import io.realm.react.RealmReactPackage;
import com.airbnb.android.react.maps.MapsPackage;

import com.BV.LinearGradient.LinearGradientPackage;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.imagepicker.ImagePickerPackage; // <-- add this import
import com.RNFetchBlob.RNFetchBlobPackage;      
import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new ReactNativePushNotificationPackage(),
            new ReactNativeDocumentPicker(),
            new RCTPdfView(),
            new RNGooglePlacesPackage(),
          new RNFetchBlobPackage() ,
            new RealmReactPackage(),
            new MapsPackage(),
           new ImagePickerPackage(),
            new LinearGradientPackage(),
            new ReactNativeConfigPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}
Stale

Most helpful comment

Update:
I added: compile project(':react-native-push-notification')
on build.gradle , now the app is crashing ... I tried almost everything. I followed the documentation carefully Still the same problem. Any Thoughts about this?

All 11 comments

Update:
I added: compile project(':react-native-push-notification')
on build.gradle , now the app is crashing ... I tried almost everything. I followed the documentation carefully Still the same problem. Any Thoughts about this?

I had the same problem, try to remove everything that you added in the bundle..etc.
And try installing again following this instruction

I fixed it , apparently I have a library that uses a different version of Google play services , so I just forced the library to use the same Google Play Services . That fixed the problem.

@PinkPanda17 just ran into the same problem. Can you explain how you fixed it?

I'm also running into the same issue, and I haven't managed to fix it. Does anyone have an example on how to get it working?

Guys here is the solution (btw, rather often fix in RN applications):
android/app/build.gradle
here we should explicitly set play-services-base version for a package:

dependencies {
    compile project(':realm')
    compile project(':react-native-streetview')
    // For animated GIF support
    compile 'com.facebook.fresco:animated-gif:1.3.0'
    compile(project(':react-native-geolocation-service')) {
        exclude group: 'com.google.android.gms', module: 'play-services-location'
    }

    compile(project(':react-native-navigation')) {
        exclude group: 'com.google.android.gms', module: 'play-services-location'
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }

    // compile project(':react-native-navigation')

    compile ('com.google.android.gms:play-services-location:11.0.4'){
        force = true;
    }

    compile project(':react-native-vector-icons')
    // ADD THIS LINES
    compile(project(':react-native-push-notification')){
       exclude group: 'com.google.android.gms', module: 'play-services-base'
    }

    compile(project(':react-native-maps')){
       exclude group: 'com.google.android.gms', module: 'play-services-base'
       exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }

    // ADD THIS LINE (all packages should use the same google-play-service version)
    compile 'com.google.android.gms:play-services-base:11.0.4' // <----
    compile 'com.google.android.gms:play-services-maps:11.0.4'

    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules

}

by adding "implementation project(':react-native-push-notification')" build successful but app crashing
react:16.2
react-native:0.52

add "compile project(':react-native-push-notification')" in build.gradle, build successful!
I need compile 3 times consecutive for successful, in administrator cmd!

Adding the following to app/build.gradle under dependencies fixed it:

implementation project(":react-native-push-notification")

Adding the following
At android/build.gradle

ext {
   ...
   googlePlayServicesVersion = "12.0.1" // default: "+"
   firebaseVersion = "12.0.1" // default: "+"
}

At android/app/build.gradle

dependencies {
    ...
    implementation project(':react-native-push-notification')
}

Worked for me. Building and NOT crashing!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nguyenvanphuc2203 picture nguyenvanphuc2203  路  3Comments

NiuQiaoling picture NiuQiaoling  路  3Comments

ssolida picture ssolida  路  3Comments

atteia picture atteia  路  4Comments

GastonEDiaz picture GastonEDiaz  路  3Comments