React-native-onesignal: error: package com.geektime.rnonesignalandroid does not exist

Created on 19 Mar 2018  ·  4Comments  ·  Source: OneSignal/react-native-onesignal

Hello,

I already saw this issue referenced and I tried the solutions proposed but it's still not working for me.
It's working on a empty project when install it but not working on my main project, so I'm wondering what could be the problem ?

However I can find the correct com.geektime.rnonesignalandroid package in node_modules\react-native-onesignal\android\src\main\java\com\geektime\rnonesignalandroid so I can't understand why it's not found.

react 16.0.0
react-native 0.54.2

My MainApplication.java

package com.XXX;

import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import android.app.Application;

import com.facebook.react.ReactApplication;
import com.AlexanderZaytsev.RNI18n.RNI18nPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.inprogress.reactnativeyoutube.ReactNativeYouTube;
import com.oblador.vectoricons.VectorIconsPackage;
import com.imagepicker.ImagePickerPackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

  protected static CallbackManager getCallbackManager() {
    return mCallbackManager;
  }

  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 ReactNativeOneSignalPackage(),

          new RNI18nPackage(), new FBSDKPackage(mCallbackManager), new ReactNativeYouTube(), new VectorIconsPackage(),
          new ImagePickerPackage(), new RNFetchBlobPackage());
    }

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

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

  @Override
  public void onCreate() {
    super.onCreate();

    FacebookSdk.sdkInitialize(getApplicationContext());
    // If you want to use AppEventsLogger to log events.

    SoLoader.init(this, /* native exopackage */ false);

    AppEventsLogger.activateApp(this);
  }
}

The ReactNativeOneSignalPackage.java in my nodes_modules

package com.geektime.rnonesignalandroid;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by Avishay on 1/31/16.
 */
public class ReactNativeOneSignalPackage implements ReactPackage {
...
}

Most helpful comment

I don't know why but the "react-native link" was not adding the line "compile project(':react-native-onesignal')" I did it manually and it's now working

Another minor problem is that the link action add each times the following lines

import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
new ReactNativeOneSignalPackage(),

The issue can be closed

All 4 comments

I don't know why but the "react-native link" was not adding the line "compile project(':react-native-onesignal')" I did it manually and it's now working

Another minor problem is that the link action add each times the following lines

import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
new ReactNativeOneSignalPackage(),

The issue can be closed

@Kisepro I'm unable to reproduce this issue. In my attempt, I created a completely new react-native project and manually added the react-native-onesignal SDK following the instructions in the readme.

Did you follow the guidance in the readme precisely to the letter? If not, how did you do it?

@Nightsd01 Yes I followed it precisely, and doing it on a completly new react-native project it works also for me.

It's really specific to my project I think and I managed to make it works when I understood why so I guess you shouldn't lose your time on that issue.

I suspect this could be because of "react-native-push-notification" linking, I had another conflict with i this package like this compile instruction

dependencies {
    compile ('com.google.android.gms:play-services-gcm:8.1.0') {
        force = true;
    }
...
}

I don't need this package anymore so it was not a big deal to remove it

I am glad to hear that resolved your issue.

We have a onesignal grade plugin that can resolve issues similar to this. It needs to be placed at the top of the App gradle file:

plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin
Was this page helpful?
0 / 5 - 0 ratings