React-native-notifications: new RNNotificationsPackage() required: Application found: no arguments

Created on 11 Sep 2019  路  10Comments  路  Source: wix/react-native-notifications

I have some error, Android, RN 60 4
懈蟹芯斜褉邪卸械薪懈械

new RNNotificationsPackage(MainApplication.this) or new RNNotificationsPackage(), nothing helps

package com.someapp;

import android.app.Application;
import android.util.Log;

import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.wix.reactnativenotifications.RNNotificationsPackage;

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() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      packages.add(new RNNotificationsPackage(MainApplication.this));
      return packages;
    }

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

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

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

Can you explane me, what's wrong?

馃彋 stale

Most helpful comment

RN60 creates autolinking packages with no arguments, to ignore that put this in root folder:

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

All 10 comments

I have same problem :(

RN60 creates autolinking packages with no arguments, to ignore that put this in root folder:

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

RN60 creates autolinking packages with no arguments, to ignore that put this in root folder:

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

And how can I test notification on Android emul after this ignore?

Please just follow docs

RN60 creates autolinking packages with no arguments, to ignore that put this in root folder:

// react-native.config.js
module.exports = {
  dependencies: {
    'react-native-notifications': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

And how can I test notification on Android emul after this ignore?

Please just follow docs

Maybe I don鈥檛 understand something, but after that it鈥檚 impossible to test notification on android?

Could you clarify? Why it's impossible?

Please follow that https://github.com/realm/realm-js/issues/2460#issue-470162630 as a example

Please follow that https://github.com/realm/realm-js/issues/2460#issue-470162630

Ok, I'll see, thx

I think the change in react-native.config.js mentioned above just disables autolinking. That then means you have manually link it 鈥撀燽y adding the usual lines in settings.gradle, app/build.gradle, and manually adding new RNNotificationsPackage(MainApplication.this) to the package list in MainApplication.java, more or less as you would have done in RN < 0.60.

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

Was this page helpful?
0 / 5 - 0 ratings