For example, a developer has developed an app that shares the location of the user to the saved contacts during an emergency on the press of a button. But the app may fail to work due to network problems or any other issue. Can the app developer be held liable for this and can actions be taken against him/her? If yes, then what is the solution for the developer?
The developer is responsible for any damage caused by using their product, unless appropriate diclaimers and limitations on liability are included. This Libre Office license provides such disclaimers in §6-7. Products are generally warranted to be "suitable for a purpose" unless there is a disclaimer that it is provided
on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing
They make no promises. They also say, as a condition for allowing you to use their product, that you agree that they bear no liability
for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages.
(Don't just copy their clauses, instead, study how these disclaimers work). As they also say, "Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages", so there may be no legal solution. If you check your contract with the phone network, you will find similar disclaimers that the network may go down and, and you can't sue them because the network went down.