react-native-webrtc / react-native-incall-manager

Handling media-routes/sensors/events during a audio/video chat on React Native
ISC License
547 stars 191 forks source link

Native Module Incall Manager tried to override IncallManagerModule #122

Open rizwan92 opened 5 years ago

rizwan92 commented 5 years ago

i am facing this error

Native Module Incall Manager tried to override IncallManagerModule . check to get Package Method in main Application.java it might be that module has been created twice. if this was your intention, set cannotOverrideExixistingmodule=True

my package.json file

 "axios": "^0.19.0",
    "openvidu-browser": "^2.11.0",
    "openvidu-node-client": "^2.11.0",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-agora": "^2.8.0-alpha.2",
    "react-native-gesture-handler": "^1.4.0",
    "react-native-incall-manager": "^3.2.4",
    "react-native-paper": "^2.16.0",
    "react-native-reanimated": "^1.2.0",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webrtc": "^1.75.0",
    "react-navigation": "^3.11.1",
    "react-navigation-material-bottom-tabs": "^1.0.0"

my Mainapplication.java file

package com.drjafar;

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.oblador.vectoricons.VectorIconsPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.swmansion.reanimated.ReanimatedPackage;
import com.syan.agora.AgoraPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.zxcpoiu.incallmanager.InCallManagerPackage;
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 InCallManagerPackage());
      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);
  }
}

my build.Gradle file

dependencies {
    implementation project(':react-native-incall-manager')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-reanimated')
    implementation project(':react-native-agora')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.android.support:support-v4:28.0.3"
    if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }
}

my graddle.settings

rootProject.name = 'drjafar'

include ':react-native-incall-manager'
project(':react-native-incall-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-incall-manager/android')

include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':react-native-agora'
project(':react-native-agora').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-agora/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

i am calling InCallManager in App.js inside componentDidMount

  componentDidMount() {
    InCallManager.start({ media: 'audio' });
  }

every thing seems fine to me what is wrong image

ruddell commented 5 years ago

Since you are using v0.60.x of React Native, dependencies should now autolink. Have you tried removing the call to packages.add(new InCallManagerPackage()); from MainApplication.java?

rizwan92 commented 5 years ago

yeah I tried that too but didn't get a response when I call this code in App.js

componentDidMount() {
    InCallManager.start({ media: 'audio' });
  }
ruddell commented 5 years ago

InCallManager.start() does not return anything. If the native library was not linked, you would get the error: null is not an object (evaluating 'InCallManager.start')

I just tested in a new v0.60.5 app with the following method, which prints "denied" since I have not granted media permissions:

setTimeout(async () => {
    const permission = await InCallManager.checkRecordPermission()
    console.log(permission)
}, 1000)

The only change I had to make after running npm install --save react-native-incall-manager was to add <uses-permission android:name="android.permission.WAKE_LOCK" /> in android/app/src/main/AndroidManifest.xml

rizwan92 commented 5 years ago

permission is granted image

  componentDidMount() {
    console.log('ahahahahah');
    setTimeout(async () => {
      const permission = await InCallManager.checkRecordPermission();
      console.log(permission);
      InCallManager.start({ media: 'audio' });
    }, 1000);
  }
rizwan92 commented 5 years ago

how to link react-native-incall-manager in RN0.60 Please update or provide docs I have followed each and every instructions

ruddell commented 5 years ago

If you get a response from that method, it is linked.

rizwan92 commented 5 years ago

i am running this app in the android pie is there any sdk updation requires additional permission ? please may i know ? which android version you ran your RN0.60 ?

rizwan92 commented 5 years ago

Can you push your latest test codes to the new repository so I can explore the codes and identify where I am doing wrong?

i want to check here at this line implementation "com.android.support:support-v4:28.0.3"

ruddell commented 5 years ago

You can see in the code of this module that checkRecordPermission calls the NativeModule, so if that returns then the module's native code is linked.

For my sample app, you can see the commit adding this library here, and the app's repository here. You don't call react-native link for React Native v0.60+

rizwan92 commented 5 years ago

branch name for this repository https://github.com/ruddell/jhipster-examples/tree/incall-manager to check demo and user id password ?

i tried registering and login dint work for me incall-manager branch

ruddell commented 5 years ago

You can see the same changes made to an app generated by react-native init in this branch, this commit. On startup, the app logs to the console what the native method returns.

For the other example, I did not deploy a backend for it so registration/login does not work. They are not necessary to test if the native module is linked. LaunchScreen.js is the screen that shows up on launch. It does not require authentication. Change console.tron.log to console.log to see the log in the browser console (or use Reactotron for logging).

rizwan92 commented 5 years ago

thanks man i am givin it a shot