Reputation: 64
I am new to twilio and i am developing a andorid app for video calling i have started with the twilio 'twilio-video-app-android' from github But app crashes when i click on join room with an exception "boolean com.twilio.video.LocalAudioTrack.isReleased()' on a null object reference" Unable to understand why is it showing this exception looking fwd to you help THANKS!
Upvotes: 1
Views: 617
Reputation: 28509
I saw the same fatal exception with the video-quickstart-android sample. I noticed that:
This is the location of the crash:
room = connect(this, accessToken, roomListener) {
roomName(roomName)
/*
* Add local audio track to connect options to share with participants.
*/
audioTracks(listOf(localAudioTrack))
/*
* Add local video track to connect options to share with participants.
*/
videoTracks(listOf(localVideoTrack))
...
But the problem is not there, it is the initialisation of the tracks that is the issue. These are only instantiated after a successful permission grant, so if the app already has the required permissions that code path is not reached, the tracks are not initialised, and the connect code blows up. Adding a single code statement into the code as follows fixed it for me in the (smaller) quickstart app:
/*
* Check camera and microphone permissions. Also, request for bluetooth
* permissions for enablement of bluetooth audio routing.
*/
if (!checkPermissionForCameraAndMicrophone()) {
Timber.i("Requesting camera and mic permissions")
requestPermissionForCameraMicrophoneAndBluetooth()
} else {
createAudioAndVideoTracks() // <------ **** ADD THIS STATEMENT ****
audioSwitch.start { audioDevices, audioDevice -> updateAudioDeviceIcon(audioDevice) }
}
@philnash I hope the quickstart sample will be updated as it badly needs it. It's not using AndroidX, is reliant on deprecated APIs (e.g. PreferenceManager), the code is littered with lint warnings, it targets the 2019 release of Android etc. It creates unnecessary pain and cost to integrate Twilio Video when samples are not kept up to date.
Upvotes: 1