skrafft / react-native-jitsi-meet

React native wrapper for Jitsi Meet SDK
Apache License 2.0
285 stars 349 forks source link

RNCNetinfo.getCurrentState got 3 arguements, expected 2 #187

Closed rassemdev closed 4 years ago

rassemdev commented 4 years ago

I'm developing an app using RN Cli. My RN version is 0.62.2. When i'm trying to implement your library using latest version, i'm getting this error message RNCNetinfo.getCurrentState got 3 arguements, expected 2. I know this error is showing in NetInfo library, but before implementing your library it was working fine. Only occurring when i'm including your library. If i exclude the NetInfo code from my component jitsi meet started working. But I need both of them in my application. Can anyone point me out what i missed! Note: my minSdkVersion is 21.

Note: my minSdkVersion is 21. and my dependencies:

"dependencies": {
    "@expo/vector-icons": "^10.2.0",
    "@react-native-community/async-storage": "^1.10.3",
    "@react-native-community/checkbox": "^0.4.1",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "^5.9.0",
    "@react-native-community/picker": "^1.6.1",
    "@react-navigation/bottom-tabs": "^5.5.1",
    "@react-navigation/drawer": "^5.8.1",
    "@react-navigation/native": "^5.5.0",
    "@react-navigation/stack": "^5.4.1",
    "native-base": "^2.13.12",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-jitsi-meet": "^2.1.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-loading-spinner-overlay": "^1.1.0",
    "react-native-reanimated": "^1.9.0",
    "react-native-responsive-screen": "^1.4.1",
    "react-native-safe-area-context": "^3.0.2",
    "react-native-screens": "^2.8.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-sweet-alert": "^2.1.0",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webview": "^10.2.3",
    "realm": "^6.0.2"
  },

One of my component:


// packages
import React, {  useContext, useEffect, useState }  from 'react';
import { Image, StyleSheet, Text, View } from 'react-native';
import { AuthContext } from './context';

// third party libraries
import { Button, Root } from 'native-base';
import Feather from 'react-native-vector-icons/Feather';
import McIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import NetInfo from "@react-native-community/netinfo";
import SpinnerOverlay from 'react-native-loading-spinner-overlay';
import AsyncStorage from '@react-native-community/async-storage';
import LinearGradient from 'react-native-linear-gradient';
import {
    widthPercentageToDP as wp,
    heightPercentageToDP as hp,
    listenOrientationChange as lor,
    removeOrientationListener as rol
} from 'react-native-responsive-screen';

// @TODO: This is to hide a Warning caused by NativeBase after upgrading to RN 0.62
import { YellowBox } from 'react-native';

YellowBox.ignoreWarnings([
    'Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`',
]);
// ------- END OF WARNING SUPPRESSION

// assets and components
import defaultImage from './../assets/avatar-default.png';

    export const DashboardScreen = ({ navigation }) => {

        const [student_details, setStudentDetails] = useState([]);
        const [isLoading, setIsLoading] = useState(false);
        const [site_url, setSiteUrl] = useState('');
        const { signOut } = useContext(AuthContext);

        useEffect(() => {
            lor();

            setIsLoading(true);

            // checking ineternet connectivity
            NetInfo.fetch().then(state => {
                if (state.isConnected && state.isInternetReachable) {
                    let getStudentDetails = async () => {
                        const userToken = await AsyncStorage.getItem('user_token');
                        const siteUrl = await AsyncStorage.getItem('site_url');
                        setSiteUrl(siteUrl);

                        // sending an api request to get student details
                        let studentDetailsResponse = await fetch(siteUrl + "/api/student_module/get_student_details", {
                            method: 'GET',
                            headers: {
                                'Accept': 'application/json',
                                'Content-Type': 'application/json',
                                'Authorization': 'Bearer ' + userToken
                            }
                        });

                        // processing the api request
                        let studentDetailsJson = await studentDetailsResponse.json();

                        if (studentDetailsJson.status == 'success') {
                            setIsLoading(false);
                            setStudentDetails(studentDetailsJson.student_details);
                        } else if (studentDetailsJson.status == 'token_error') {
                            setIsLoading(false);
                            signOut();
                        } else if (studentDetailsJson.error == 'token_expired') {
                            setIsLoading(false);
                            signOut();
                        } else {
                            setIsLoading(false);

                            Toast.show({
                                text: studentDetailsJson.message,
                                buttonText: "Okay",
                                type: "warning",
                                duration: 30000
                            });
                        }
                    }

                    getStudentDetails();
                } else {
                    setIsLoading(false);

                    Toast.show({
                        text: 'No internet connection!',
                        buttonText: "Okay",
                        type: "warning",
                        duration: 30000
                    });
                }
            });

            return () => {
                rol();
            };
        }, []);

        const onlinePayment = () => {
            navigation.navigate('OnlinePayment');
        }

        const homework = () => {
            navigation.navigate('Homework');
        }

        const syllabus = () => {
            navigation.navigate('Syllabus');
        }

        const onlineClassroom = () => {
            navigation.navigate('OnlineClass');
        }

        const styles = StyleSheet.create({
            header: {
                paddingTop: hp("3%"),
                height: hp("32%"),
                borderBottomLeftRadius: 20,
                borderBottomRightRadius: 20,
                backgroundColor: "#ff3542"
            },
            dashboardText: {
                color: "#FFFFFF",
                fontSize: 20,
                fontWeight: 'bold',
                alignSelf: 'center'
            },
            dashboardView: {
                marginLeft: 'auto',
                marginRight: 'auto',
                marginTop: -40,
                paddingLeft: wp("5%"),
                paddingRight: wp("5%"),
                width: '85%',
                display: 'flex',
                flexDirection: 'row',
                justifyContent: 'space-around',
                flexWrap: 'wrap',
            },
            menuView: {
                display: 'flex',
                flexDirection: 'column'
            },
            dashboardCategory: {
                height: 80,
                width: 80,
                borderRadius: 5,
                elevation: 5,
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'center',
                backgroundColor: '#FFFFFF'
            },
            iconStyle: {
                color: 'grey',
                fontSize: 35
            },
            buttonText: {
                marginTop: 10,
                paddingBottom: hp("2%"),
                color: '#4b2e80',
                width: '100%',
                textAlign:'center',
                fontSize: wp("3.9%")
            },
            defaultImage: {
                marginTop: hp("3%"),
                borderRadius: 50,
                width: hp("10%"),
                height: hp("10%"),
                marginRight: hp("2%"),
                marginLeft: wp("12%")
            },
            studnetDetailsWrapper: {
                marginTop: hp("1.7%"),
                display: 'flex',
                flexDirection: 'row',
                alignItems: 'center'
            },
            studentDetailsView: {
                marginTop: hp("3%"),
                paddingLeft: wp("4%")
            }
        });

        return (
            <Root>
                <SpinnerOverlay
                    visible={isLoading}
                    textContent={'Getting Student Details...'}
                    textStyle={styles.spinnerTextStyle}
                />

                <LinearGradient
                    start={{x: 0, y: 0}}
                    end={{x: 1, y: 0}}
                    colors={['#ff1a29', '#ff3542', '#ff4d58', '#ff8088']}
                    style={styles.header}>

                    <Button
                        transparent
                        style={{ position: 'absolute', left: wp("5%"), top: hp("1.8%") }}
                        onPress={() => navigation.openDrawer()}>
                        <Feather style={{ color: '#FFFFFF' }} name="menu" size={28} />
                    </Button>
                    <Text style={styles.dashboardText}>DASHBOARD</Text>

                    <View style={styles.studnetDetailsWrapper}>
                        {student_details.profile_image ? <Image source={{ uri: site_url + "/img/StudentPicture/" + student_details.profile_image }} style={styles.defaultImage} /> : <Image source={ defaultImage } style={styles.defaultImage} /> }

                        <View style={{ marginTop: hp("4%"), borderLeftWidth: 2, width: 2, height: 35, borderColor: "#FFFFFF" }}></View>

                        <View style={styles.studentDetailsView}>
                            <Text style={{ color: "#FFFFFF", fontWeight: 'bold', fontSize: hp("2.1%") }}>
                                {student_details.student_name}
                            </Text>

                            <View>
                                <Text style={{ color: "#FFFFFF", fontWeight: 'bold', fontSize: hp("1.9%"), marginTop: hp("0.2%") }}>
                                    Class:  {(typeof student_details.class_info !== 'undefined' && typeof student_details.class_info.ClassName !== 'undefined') ? student_details.class_info.ClassName : '-'}   |   Roll:  {student_details.roll_no}
                                </Text>
                                <Text style={{ color: "#FFFFFF", fontWeight: 'bold', fontSize: hp("1.9%"), marginTop: hp("0.2%") }}>
                                    Section:  {(typeof student_details.section !== 'undefined' && typeof student_details.section.SectionName !== 'undefined') ? student_details.section.SectionName : '-'}   |   Group:  {(typeof student_details.group !== 'undefined' && typeof student_details.group.GroupName !== 'undefined') ? student_details.group.GroupName : '-'}
                                </Text>
                            </View>
                        </View>
                    </View>
                </LinearGradient>

                <View style={styles.dashboardView}>
                    <View style={styles.menuView}>
                        <Button light style={styles.dashboardCategory} onPress={homework}>
                            <Feather style={styles.iconStyle} name="book" size={25} />
                        </Button>
                        <Text style={styles.buttonText}> Homework </Text>
                    </View>

                    <View>
                        <Button light style={styles.dashboardCategory} onPress={syllabus}>
                            <Feather style={styles.iconStyle} name="book-open" size={25} />
                        </Button>
                        <Text style={styles.buttonText}> Syllabus </Text>
                    </View>

                    <View>
                        <Button light style={styles.dashboardCategory} onPress={onlinePayment}>
                            <Feather style={styles.iconStyle} name='dollar-sign' size={25} />
                        </Button>
                        <Text style={styles.buttonText}> Pay Online </Text>
                    </View>

                    <View>
                        <Button light style={styles.dashboardCategory} onPress={onlineClassroom}>
                            <McIcons style={styles.iconStyle} name='google-classroom' size={25} />
                        </Button>
                        <Text style={styles.buttonText}> Online Class </Text>
                    </View>
                </View>
            </Root>
        )
    }
rassemdev commented 4 years ago

I have excluded those packages while implementing jitsi-meet sdk, now my other pages are working fine, except the video conference page where the jitsi-meet will run.

    implementation ('org.jitsi.react:jitsi-meet-sdk:2.+') {
        exclude group: 'com.facebook',module:'hermes'
        exclude group: 'com.facebook.react',module:'react-native-vector-icons'
        exclude group: 'com.facebook.react',module:'react-native-community-async-storage'
        exclude group: 'com.facebook.react',module:'react-native-webview'
        exclude group: 'com.facebook.react',module:'react-native-community_netinfo'
        exclude group: 'com.facebook.react',module:'react-native-linear-gradient'
        transitive = true
    }

Now i'm getting this error, (it is showing after the app crashes)

com.facebook.react.bridge.NativeArgumentsParseException: RNCNetInfo.getCurrentState got 2 arguments, expected 3

any ideas!

anshumanburman commented 4 years ago

just update NetInfo with 5.00 version from the community.

rassemdev commented 4 years ago

@anshumanburman, i already solved it, but thanks for your time, after excluding them from build.gradle, i downgraded my netindo to 4.6^. That solved my problem

dgreasi commented 2 years ago

The problem is with the version of '@react-native-community/netinfo' library. I built the jitsi-meet sdk after upgrading the library to v5.0.0, which is what i use in my project too.