Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29577

React native "Attempt to invoke virtual method 'android.app.Activity.showdShowRequestPermissionRationale' on a null object reference"

$
0
0

I'm trying to incorporate Twilio voice using the react-native-twilio-programmable-voice package. My app loads on ios, but when running on android I get this error message

Attempt to invoke virtual method 'boolean android.app.Activity.shouldShowRequestPermissionRationale' on a null object referencescreenshot here

I've included <uses-permission android:name="android.permission.RECORD_AUDIO" /> in AndroidManifest.xml

and none of the TwilioVoice related functions are called until 4 or 5 screens into the app.

Been scratching my head for a few days now, any help is greatly appreciated.

Code snippet of my Twilio helper class:

import TwilioVoice from 'react-native-twilio-programmable-voice';import {Platform} from 'react-native';import config from '../config/Config';export default class Voip{  constructor(props) {      this.state = {  };}  async setupDeviceWithToken(accessToken){    console.log('V32: setup device', accessToken);    TwilioVoice.addEventListener('deviceReady', () => this.deviceReadyHandler());    TwilioVoice.addEventListener('deviceNotReady', () => this.deviceNotReadyHandler());    TwilioVoice.addEventListener('connectionDidConnect', () => this.connectionDidConnectHandler());    TwilioVoice.addEventListener('connectionDidDisconnect', () => this.connectionDidDisconnectHandler());if(Platform.OS === 'ios'){  TwilioVoice.addEventListener('callRejected', this.callRejected());} else if (Platform.OS === 'android'){  TwilioVoice.addEventListener('deviceDidReceiveIncoming', this.deviceDidReceiveIncomingHandler());}var success;try {      success = await TwilioVoice.initWithToken(accessToken);      console.log('V36: ', success);      //return success;  }catch(err){      console.log('V40: ' ,err);      return err;  }  // if(Platform.OS === 'ios')  // {      try {          TwilioVoice.configureCallKit({              appName:       'VoipApp'                  // Required param          })          console.log('V50: ios success');          //return 'success';      }      catch (err) {          console.log('V54: ',err);          return err;      }  // }  return success;}

Viewing all articles
Browse latest Browse all 29577