react-native-notifications: error building on android: cannot find symbol packages.add(new RNNotificationsPackage(MainApplication.this));
Hi I’m trying to build the app on android , but I’'m getting the following error, i’ve tried to change it to my package name but also doesnt work :
im using “react-native”: “0.61.5”,
F:\REACT NATIVE wixlocalnotifi\android\app\src\main\java\com\wixlocalnotifi\MainApplication.java:12: error: package com.wix.reactnativenotifications does not exist import com.wix.reactnativenotifications.RNNotificationsPackage; ^ F:\REACT NATIVE PURO\wixlocalnotifi\android\app\src\main\java\com\wixlocalnotifi\MainApplication.java:33: error: cannot find symbol packages.add(new RNNotificationsPackage(MainApplication.this));
My MainApplication.java code:
package com.wixlocalnotifi;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import com.wix.reactnativenotifications.RNNotificationsPackage;
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);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
This should be covered with #522 it’s marged so it probably will be in next release but until then just remove any manual linking code you added and change your
react-native.config.jsfile with new one.Is this project still being supported? I don’t see any movement and they’re a lot of people having issues around this library, the documentation is not updated and is just causing issues.
Should we move to a different library? I haven’t seen any resolution to all the problems, I mean, not even auto-linking is supported.
Also even with the latest update, this library doesn’t work at all, I’m just getting a new error if I follow your instructions
Having same issue. Frustrating.
I have same issue, but sovled this problem today. maybe you didn’t setup gradle files. check this link: https://wix.github.io/react-native-notifications/docs/installation-android