Cannot connect to Nikon D5300 via WiFi from Android 7.1.2+
This procedure requires root access.


Install a terminal such as ConnectBot (F-Droid, Play Store)
Type su
Type this command: settings put global captive_portal_mode 0
Press Enter
That's all, the connection should work immediately.




 Screenshot (click image for a larger variant)

Explanation: Since 7.1.2 Android has changed the way captive portals are handled, and the camera's WiFi, which does not give access to the Internet, is considered a captive portal and since it does not reply as expected the connection is gets dropped. Setting the captive_portal_mode variable to 0 prevents Android from doing that.

Details: https://github.com/LineageOS/android_frameworks_base/blob/cm-14.1/core/java/android/provider/Settings.java#L8268

(By the way, for devices with an Android version earlier than 7.1.2 the command is settings put global captive_portal_detection_enabled 0)