For single SIM following code works:
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); String imei= tm.getDeviceId();
Try using getDeviceId(int slotId) added in API level 23.
Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available. Requires Permission: READ_PHONE_STATE
Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available.
Requires Permission: READ_PHONE_STATE
READ_PHONE_STATE