Argument 1 passed to EntityViewBuilder must implement interface, null given In my Drupal project I have this error:

Recoverable fatal error: Argument 1 passed to Drupal\Core\Entity\EntityViewBuilder::view() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in /Users/team1/workspace/ga_p/modules/field_collection/src/Plugin/Field/FieldFormatter/FieldCollectionItemsFormatter.php on line 33 and defined in Drupal\Core\Entity\EntityViewBuilder->view() (line 110 of core/lib/Drupal/Core/Entity/EntityViewBuilder.php).


I do not know if it's from having created multiple fields (fieldCollections)

But I do not know how to remove this error.

Drupal Version: 8.3.4
Try this patch

diff --git a/src/Plugin/Field/FieldType/FieldCollection.php b/src/Plugin/Field/FieldType/FieldCollection.php
index 8721220..c5335be 100644
--- a/src/Plugin/Field/FieldType/FieldCollection.php
+++ b/src/Plugin/Field/FieldType/FieldCollection.php
@@ -183,19 +183,15 @@ class FieldCollection extends EntityReferenceItem {
   public function preSave() {

     if ($field_collection_item = $this-&gt;getFieldCollectionItem()) {
-      // TODO: Handle node cloning
-      /*
-      if (!empty($host_entity-&gt;is_new) &amp;&amp; empty($entity-&gt;is_new)) {
+      $host = $this-&gt;getEntity();
+
+      // Handle node cloning
+      if($host-&gt;isNew() &amp;&amp; !$field_collection_item-&gt;isNew()) {
         // If the host entity is new but we have a field_collection that is not
         // new, it means that its host is being cloned. Thus we need to clone
         // the field collection entity as well.
-        $new_entity = clone $entity;
-        $new_entity-&gt;target_id = NULL;
-        $new_entity-&gt;revision_id = NULL;
-        $new_entity-&gt;is_new = TRUE;
-        $entity = $new_entity;
+        $field_collection_item = $field_collection_item-&gt;createDuplicate();
       }
-      */

       // TODO: Handle deleted items
       /*
@@ -231,11 +227,10 @@ class FieldCollection extends EntityReferenceItem {
       }
       */

-      $this-&gt;newHostRevision = $this-&gt;getEntity()-&gt;isNewRevision();
+      $this-&gt;newHostRevision = $host-&gt;isNewRevision();

       // If the host entity is saved as new revision, do the same for the item.
       if ($this-&gt;newHostRevision) {
-        $host = $this-&gt;getEntity();

         $field_collection_item-&gt;setNewRevision();

diff --git a/src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php b/src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php
index 4d6ae09..800383f 100644
--- a/src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php
+++ b/src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php
@@ -104,9 +104,8 @@ class FieldCollectionEmbedWidget extends WidgetBase {
   protected function formMultipleElements(FieldItemListInterface $items, array &amp;$form, FormStateInterface $form_state) {
     // We don't want to render empty items on field collection fields
     // unless a) the field collection is empty ; b) the form is rebuilding,
-    // which means that the user clicked on "Add another item"; or
-    // c) we are creating a new entity.
-    if ((count($items) &gt; 0) &amp;&amp; !$form_state-&gt;isRebuilding() &amp;&amp; !$items-&gt;getEntity()-&gt;isNew()) {
+    // which means that the user clicked on "Add another item"
+    if ((count($items) &gt; 0) &amp;&amp; !$form_state-&gt;isRebuilding()) {
       $field_name = $this-&gt;fieldDefinition-&gt;getName();
       $cardinality = $this-&gt;fieldDefinition-&gt;getFieldStorageDefinition()-&gt;getCardinality();
       $parents = $form['#parents'];


mentioned here.