react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

error: package com.dieam.reactnativepushnotification does not exist

Open TOAO1 opened this issue 8 years ago • 15 comments

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!

TOAO1 avatar Aug 20 '18 13:08 TOAO1

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:

Gp2mv3 avatar Aug 20 '18 17:08 Gp2mv3

Really sorry about that.

TOAO1 avatar Aug 21 '18 00:08 TOAO1

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

tmmgn avatar Aug 21 '18 08:08 tmmgn

Can you try with those config ?


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

Gp2mv3 avatar Aug 21 '18 08:08 Gp2mv3

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

tmmgn avatar Aug 21 '18 09:08 tmmgn

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.

welladam avatar Aug 22 '18 18:08 welladam

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.

thomasdreyer avatar Sep 03 '18 14:09 thomasdreyer

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')

RolyMolnar avatar Sep 14 '18 11:09 RolyMolnar

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!

coffeeexistence avatar Oct 08 '18 19:10 coffeeexistence

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

TOAO1 avatar Oct 08 '18 23:10 TOAO1

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

abn0rmal-d0ct0r avatar Feb 02 '19 12:02 abn0rmal-d0ct0r

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

inkwaris avatar Feb 21 '19 07:02 inkwaris

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.

github-actions[bot] avatar May 23 '20 00:05 github-actions[bot]

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"

Bsingh2697 avatar Jun 19 '20 10:06 Bsingh2697

In my case, I made the changes in the vscode instead of the Android Studio. To solve it I had to enter android studio and sync the project.

JoseVov avatar Apr 02 '24 14:04 JoseVov