Error code 31 is a general Android error that can occur when trying to install or update an app. The full error message is usually Install failed with error code 31, but it may also just say error code 31. This error typically occurs when there is a problem with the network connection, storage space, or security permissions on the device. Sometimes it can also be caused by a corrupt app file.
There are a few things you can try to fix this problem. First, make sure you have a strong and stable internet connection. If you're using Wi-Fi, try moving closer to the router or connecting to a different Wi-Fi network. If you're using cellular data, try turning on airplane mode for a minute and then turning it back off. This will sometimes reset the connection and allow the installation to continue.
If that doesn't work, try clearing your device's cache and data. To do this, go to Settings > Apps > [app name] > Storage and tap Clear Cache and Clear Data buttons. Note that this will delete any data associated with the app, so only do this if you're sure you don't need it anymore.
If those steps don't fix the problem, then the next thing to try is uninstalling any other apps that might be causing conflicts. Sometimes two apps can interfere with each other and cause errors like this one. To see if that's the case here, start by uninstalling any recently installed apps (especially ones from unknown sources). If that doesn't help either, then your best bet is probably to factory reset your device and start fresh again.