getPushRegistrationId(final Callback callback) { if (!isFirebaseInstanceIdAvailable()) { return; } Task<InstanceIdResult> task; try { task = FirebaseInstanceId.getInstance().getInstanceId(); } catch (NoSuchMethodError e) { return; } task.addOnCompleteListener(...) } private static boolean isFirebaseInstanceIdAvailable() { try { Class.forName("com.google.firebase.iid.FirebaseInstanceId } catch (ClassNotFoundException e) { return false; }