Attempt to invoke virtual method com.google.firebase.iid.FirebaseInstanceId.getInstanceId()' on a null object reference

There was problem in merged manifest, following service was missing from the merged manifest. Added same to AndroidManifest.xml it worked like a charm.

 <service android:name="com.google.firebase.components.ComponentDiscoveryService" >
            <meta-data
                android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
 </service>

Everything is working fine now.