In the file /data/system/device_policies.xml
remove everything and add the following lines,
For Lollipop 5.x.x:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<policies setup-complete="true">
<admin name="net.dinglisch.android.taskerm/net.dinglisch.android.taskerm.MyDeviceAdminReceiver">
<policies flags="8" />
</admin>
</policies>
For Android 4.2.1:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<policies>
<admin name="net.dinglisch.android.taskerm/net.dinglisch.android.taskerm.MyDeviceAdminReceiver">
<policies flags="8" />
</admin>
</policies>
Reboot the device and Tasker would now be found enabled as Device administrator. However, all other apps previously enabled as Device administrator would eventually be found stripped from that privilege. You would have to manually grant them the privilege from Settings app.
For any reasoning, see my answer here: How to enable device administrator for specific apps using Tasker?