React-native-push-notification: error: package com.dieam.reactnativepushnotification does not exist

Created on 20 Aug 2018  路  14Comments  路  Source: zo0r/react-native-push-notification

I have been trying to use react-n-push-notification in my project;

react-native: 0.52
react-native-push-notification: 3.1.1

in android/buid.gradle

add to the bottom of the file

ext {
googlePlayServicesVersion = "+" // default: "+"
firebaseVersion = "+" // default: "+"

// Other settings
compileSdkVersion = 23 // default: `23`
buildToolsVersion = "23.0.1" // default: "23.0.1"
targetSdkVersion = 23 // default: 23
supportLibVersion = "23.1.1" // default: 23.1.1

}

added all the services in android manifest file, and import package in mainApplication.java like this

package com.pnotifirebase;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;  // <--- Import Package


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() // <---- Add the Package
      );
    }

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

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

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

`

when i try react-native run-android it reported error:

C:\newApp\pNotiFireBase\android\app\src\main\java\com\pnotifirebase\MainApplication.java:10: error: package com.dieam.reactnativepushnotification does not exist
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;  // <--- Import Package
                                            ^
C:\newApp\pNotiFireBase\android\app\src\main\java\com\pnotifirebase\MainApplication.java:28: error: cannot find symbol
          new ReactNativePushNotificationPackage() // <---- Add the Package
              ^
  symbol: class ReactNativePushNotificationPackage
2 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get `more` log output.

Help me please!

Stale help wanted question

Most helpful comment

In android/app/gradle.build file make sure the following line exists, if not add it and try building your app again :
implementation project(':react-native-push-notification')

not sure if it will solve your issue, but it did mine.

All 14 comments

Can you change that title to be more explicit please ? And use markdown to be clearer. It's really not encouraging to help you with that presentation. :confused:

Really sorry about that.

I have the same error after fresh install step-by-step

Can you try with those config ?

ext {
    buildToolsVersion = "26.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

Just tried this solution, nothing changed, error still the same

To fix this, in my case, I update to react: ^16.4.2 and react-native: ^0.56.0.
I had to update the babel and others libraries too.

In android/app/gradle.build file make sure the following line exists, if not add it and try building your app again :
implementation project(':react-native-push-notification')

not sure if it will solve your issue, but it did mine.

In android/app/gradle.build file make sure the following line exists, if not add it and try building your app again :
implementation project(':react-native-push-notification')

not sure if it will solve your issue, but it did mine.

it's compile project(':react-native-push-notification')

Ah! @thomasdreyer that fixed it for me! Usually, RN plugin docs mention to add:

compile project(':react-native-push-notification')

but this one didn't and I ended up forgetting to do so and spent an hour trying to figure out why this wouldn't work!

I just switch to react-native-firebase, that's easier solution.

In android/app/gradle.build file make sure the following line exists, if not add it and try building your app again :
implementation project(':react-native-push-notification')
not sure if it will solve your issue, but it did mine.

it's compile project(':react-native-push-notification')

Unfortunately, this didnt help me. Someone help me pls.

Any help is greatly appreciated

In android/app/gradle.build file make sure the following line exists, if not add it and try building your app again :
implementation project(':react-native-push-notification')

not sure if it will solve your issue, but it did mine.

this should be add in doc

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.

In my case what happened was, actually in package.json dependencies, these two dependencies were missing even after installing

"react-native-permissions": "^2.1.5",
"react-native-push-notification": "^3.5.2"
Was this page helpful?
0 / 5 - 0 ratings