I want to use assert obj != null : \"object cannot be null\"
on Android device. The assert doesn\'t seem to work, so I searched online and I found this local so
Tested on Android 4.x device, it is possible to use Java assert on Android device:
Now your Android device is sensible to assert checks, and will throw AssertionError when assert check fails.
EDIT:
Another easy approach, enabling asserts from PC until device is restarted:
platform-tools\adb shell setprop debug.assert 1
You may for example create a .bat file (on Windows) and run it when device is attached.