"Obtaining IP address" when connecting to WiFi
Beginning with with Marshmallow (possibly Lollipop, I was on it for such a short time I can't remember), there is an option in Settings,  Backup &amp; Reset called "Network Settings Reset" described here. This will reset all network settings only in the device, leaving other data intact. Note that all your WiFi passwords and any security certificates will be removed as well, but this will often correct the error you describe.