title: RecyclerView not showing anything even after receiving data
body: <p>I am trying to populate some data on a <code>RecyclerView</code>. The data is obtained in one of the ways:  </p>
  
  <ol>
  <li>Request data from an API if internet is present (using <code>Retrofit</code> and <code>RxJava2</code>), persist the data to local database (using <code>Room</code>), send the data to the <code>View</code> (in my case it is a <code>Fragment</code>).</li>
  <li>If no internet then get data from the local database and send it to the <code>View</code>.</li>
  </ol>
  
  <p><strong>I'm using MVP as the application architecture and I'm using <code>ViewModels</code> to deal with the data handling for the UI. I am using <code>ButterKnife</code> to do the view finding.</strong></p>
  
  <p>The <code>Presenter</code> calls the <code>Repository</code>, which gets the data based on the conditions specified above and then the data is sent to the <code>Views</code> by the <code>Presenter</code> where the <code>ViewModel</code> intercepts the data and does the necessary steps to pass the data to the UI elements (the <code>RecyclerView</code> adapter update).  </p>
  
  <p>My problem is:  </p>
  
  <ol>
  <li>Even when I see in the debugger that the data is reaching to <code>RecyclerViewAdapter</code>, the screen is blank. No data is shown.</li>
  <li>The result from the local database throws <code>IllegalStateException</code>, saying that local db cannot be accessed from the main thread, even when I <code>subscribeOn(Schedulers.io())</code> when I'm calling the function to return the data from local db, which return a <code>Maybe&lt;&gt;</code>.  </li>
  </ol>
  
  <p>My code is as follows:<br>
  The repository:  </p>
  
  <pre><code>public class CountriesListApiRepository {
      private final IRestServiceDataFetcher restServiceDataFetcher; // Retrofit interface to get data from API
  
      @Inject
      public CountriesListApiRepository(IRestServiceDataFetcher restServiceDataFetcher) {
          this.restServiceDataFetcher = restServiceDataFetcher;
      }
  
      public Maybe&lt;List&lt;CountriesFullEntity&gt;&gt; getCountriesFromApi() {
          return restServiceDataFetcher
                  .getListOfCountriesData()
                  .observeOn(AndroidSchedulers.mainThread())
                  .subscribeOn(Schedulers.io());
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class CountriesListLocalDbRepository {
      private final CountriesLocalDb countriesLocalDb;
  
      @Inject
      CountriesListLocalDbRepository(CountriesLocalDb countriesLocalDb) {
          this.countriesLocalDb = countriesLocalDb;
      }
  
      Maybe&lt;List&lt;CountriesFullEntity&gt;&gt; getCountriesFromLocalDb() {
          return this.countriesLocalDb
                  .getCountriesLocalDbDAO()
                  .getCountriesList()
                  .observeOn(Schedulers.io())
                  .subscribeOn(Schedulers.io());
      }
  
      void updateLocalDb(List&lt;CountriesFullEntity&gt; updatedCountriesList) {
          countriesLocalDb.getCountriesLocalDbDAO().insertAllCountries(updatedCountriesList);
  
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class CountriesListRepository {
      private final CountriesListApiRepository countriesListApiRepository;
      private final CountriesListLocalDbRepository countriesListLocalDbRepository;
      private static final String TAG_CountriesListRepository = "CountriesListRepository";
  
      @Inject
      public CountriesListRepository(CountriesListApiRepository countriesListApiRepository,
                                     CountriesListLocalDbRepository countriesListLocalDbRepository) {
          this.countriesListApiRepository = countriesListApiRepository;
          this.countriesListLocalDbRepository = countriesListLocalDbRepository;
      }
  
      public Maybe&lt;List&lt;CountriesFullEntity&gt;&gt; getCountries() {
          return this.countriesListApiRepository
                  .getCountriesFromApi()
                  .doOnSuccess(this.countriesListLocalDbRepository::updateLocalDb)
                  .doOnError(throwable -&gt; {
                      Log.d(TAG_CountriesListRepository,throwable.getMessage());
                      throwable.printStackTrace(); })
                  .onErrorResumeNext(this.countriesListLocalDbRepository.getCountriesFromLocalDb());
      }
  }  
  </code></pre>
  
  <hr>
  
  <hr>
  
  <p>My Presenter:  </p>
  
  <pre><code>public class BasePresenter&lt;T extends BaseView&gt; {
      @Inject
      T injectedView;
  
      private static final String TAG_BASE_PRESENTER = "BasePresenter";
  
      T getInjectedView() {
          return injectedView;
      }
  
      &lt;V&gt; void subscribeToObserver(Maybe&lt;V&gt; flowable, MaybeObserver&lt;V&gt; maybeObserver) {
          flowable.subscribeOn(Schedulers.io())
                  .observeOn(AndroidSchedulers.mainThread())
                  .doOnSubscribe(subscription -&gt; Log.d(TAG_BASE_PRESENTER,"Subscribed"))
                  .doOnSuccess(v -&gt; Log.d(TAG_BASE_PRESENTER,"onNext() completed"))
                  .subscribe(maybeObserver);
      }
  }  
  </code></pre>
  
  <hr>
  
  <pre><code>public class CountriesListPresenter extends BasePresenter&lt;CountriesListView&gt;
          implements MaybeObserver&lt;List&lt;CountriesFullEntity&gt;&gt; {
  
      private static final String TAG_ListPresenter = "CountriesListPresenter";
  
      private final CountriesListRepository countriesListRepository;
  
      private Disposable disposable;
  
      @Inject
      public CountriesListPresenter(CountriesListRepository countriesListRepository) {
          this.countriesListRepository = countriesListRepository;
      }
  
      public void getCountries() {
          Maybe&lt;List&lt;CountriesFullEntity&gt;&gt; listOfCountriesData = this.countriesListRepository
                  .getCountries();
          subscribeToObserver(listOfCountriesData, this);
      }
  
      public void updateCountriesList(@NonNull Boolean isInternetThere) {
          Maybe&lt;List&lt;CountriesFullEntity&gt;&gt; newCountriesFullData = this.countriesListRepository
                  .updateCountriesList(isInternetThere);
          subscribeToObserver(newCountriesFullData,this);
      }
  
      @Override
      public void onSubscribe(Disposable d) {
          this.disposable = d;
      }
  
      @Override
      public void onSuccess(List&lt;CountriesFullEntity&gt; countriesFullEntities) {
          Log.d(TAG_ListPresenter,"Executing onNext()");
          getInjectedView().onLoadCountriesDataFull(countriesFullEntities);
      }
  
      @Override
      public void onError(Throwable e) {
          Log.d(TAG_ListPresenter,"Executing onError()",e);
          getInjectedView().onErrorEncountered(e.getMessage());
      }
  
      @Override
      public void onComplete() {
          if(!disposable.isDisposed()) disposable.dispose();
      }
  }  
  </code></pre>
  
  <hr>
  
  <hr>
  
  <p>My Views:  </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements IFragmentToFragmentMediator, SwipeRefreshLayout.OnRefreshListener {
  
      public static final String TAG_MAIN_ACTIVITY = "MainActivity";
  
      public static final String TAG_LIST_FRAGMENT = "COUNTRY_LIST";
      public static final String TAG_DETAILS_FRAGMENT = "COUNTRY_DETAILS";
  
      @BindView(R.id.MainActSwipeRefreshLayout)
      SwipeRefreshLayout swipeRefreshLayout;
  
      private Unbinder unbinder;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          unbinder = ButterKnife.bind(this);
          swipeRefreshLayout.setOnRefreshListener(this);
          Configuration config = getResources().getConfiguration();
          Log.d(TAG_MAIN_ACTIVITY,"Main Activity View Created");
          if(config.smallestScreenWidthDp&lt;600){
              CountriesListFrag countriesListFrag = new CountriesListFrag();
              conductFragmentTransaction(countriesListFrag,TAG_LIST_FRAGMENT, false, true);
              Log.d(TAG_MAIN_ACTIVITY,"Main Activity &lt; 600 and portrait");
          }
      }
  
      @Override
      public void onBackPressed() {
          super.onBackPressed();
          FragmentManager fm = getSupportFragmentManager();
          if(getSupportFragmentManager().getBackStackEntryCount() &gt; 1) {
              Fragment f = fm.findFragmentByTag(TAG_DETAILS_FRAGMENT);
              if (f instanceof  CountryDetailsFrag) fm.popBackStack();
              else this.finish();
          }
      }
  
      @Override
      public void onRefresh() {
          // TODO : Code the refreshing data callback here
          Fragment countryListFragment = returnNonNullRunningFragmentByTagName(TAG_LIST_FRAGMENT);
          Fragment countryDetailsFragment = returnNonNullRunningFragmentByTagName(TAG_DETAILS_FRAGMENT);
          makeViewsSignalUpdateOfData((CountriesListFrag)countryListFragment);
          makeViewsSignalUpdateOfData((CountryDetailsFrag)countryDetailsFragment);
      }
  
      @Override
      public void invokeDetailsFragmentOnListItemCLickedInListFragment(CountriesFullEntity countriesFullEntity) {
          CountryDetailsFrag countryDetailsFrag = CountryDetailsFrag.newInstance();
          Bundle data = new Bundle();
          data.putSerializable("data",countriesFullEntity);
          countryDetailsFrag.setArguments(data);
          conductFragmentTransaction(countryDetailsFrag, TAG_DETAILS_FRAGMENT, false, true);
      }
  
      @Override
      public void invokeDetailsFragmentOnListItemClickedInListFragmentViewModel() {
  
          CountryDetailsFrag countryDetailsFrag =
                  (CountryDetailsFrag) getSupportFragmentManager().findFragmentByTag(TAG_DETAILS_FRAGMENT);
  
          if(countryDetailsFrag!=null &amp;&amp; countryDetailsFrag.isVisible())
          conductFragmentTransaction(countryDetailsFrag, TAG_DETAILS_FRAGMENT, true, true);
      }
  
      private void makeViewsSignalUpdateOfData(BaseView view) {
          if(view != null) view.onPerformUpdateAction();
      }
  
      private Fragment returnNonNullRunningFragmentByTagName(String tagName) {
          Fragment fragmentForProcessing = getSupportFragmentManager().findFragmentByTag(tagName);
          if(fragmentForProcessing!=null &amp;&amp; fragmentForProcessing.isVisible()) return fragmentForProcessing;
          return null;
      }
  
      private void conductFragmentTransaction(Fragment targetFragment, String tag, boolean addOrReplaceFlag, boolean backStackFlag) {
          FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
          if(addOrReplaceFlag)fragmentTransaction.replace(R.id.fragmentCanvas,targetFragment,tag);
          else fragmentTransaction.add(R.id.fragmentCanvas,targetFragment,tag);
          if(backStackFlag)fragmentTransaction.addToBackStack(null);
          fragmentTransaction.commit();
      }
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
          unbinder.unbind();
      }
  }  
  </code></pre>
  
  <hr>
  
  <pre><code>public class CountriesListFrag extends Fragment implements CountriesListView {
  
      public static final String TAG_LIST_FRAGMENT = "ListFragment";
  
      @Inject
      Picasso picasso;
      @Inject
      CountriesListPresenter countriesListPresenter;
  
      private IFragmentToFragmentMediator listeningActivity;
      private Frag2FragCommViewModel frag2FragCommViewModel;
  
      @BindView(R.id.CountriesEntireHolderRV)
      RecyclerView countriesEntireHolderRV;
      private CountriesListRecyclerViewAdapter countriesListRecyclerViewAdapter;
      private Unbinder unbinder;
  
      public CountriesListFrag() {
      }
  
      @Override
      public void onAttach(Context context) {
          DaggerCountryComponents
                  .builder()
                  .appComponents(((CentralApplication)context.getApplicationContext())
                          .getAppComponents())
                  .countryModule(new CountryModule(this))
                  .build()
                  .inject(this);
          super.onAttach(context);
          try{
              this.listeningActivity = (MainActivity) context;
  
              this.frag2FragCommViewModel = ViewModelProviders
                      .of((MainActivity) context)
                      .get(Frag2FragCommViewModel.class);
          } catch (ClassCastException e) {
              throw new ClassCastException(context.toString() + " must implement IFragmentToFragmentMediator");
          }
      }
  
      @Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
      }
  
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.fragment_countries_list, container, false);
          if(v!=null) this.unbinder = ButterKnife.bind(this,v);
  
          // Inflate the layout for this fragment
          initialize();
          this.countriesListPresenter.getCountries();
          setUpListItemClickListener();
  
          frag2FragCommViewModel
                  .getLiveDataListOfCountriesData()
                  .observe(this,countriesFullEntities -&gt;
                          countriesListRecyclerViewAdapter.setCountriesFullEntityList(countriesFullEntities));
          Log.d(TAG_LIST_FRAGMENT,"List Fragment View Created");
  
          return v;
      }
  
      @Override
      public void onLoadCountriesDataFull(List&lt;CountriesFullEntity&gt; countriesFullData) {
  //        this.countriesListRecyclerViewAdapter.setCountriesFullEntityList(countriesFullData);
          Log.d(TAG_LIST_FRAGMENT,"Data Received in List Fragment");
          Log.d(TAG_LIST_FRAGMENT,countriesFullData.get(0).getName());
          this.frag2FragCommViewModel.setListOfCountriesData(countriesFullData);
      }
  
      @Override
      public void onErrorEncountered(String errorMessage) {
          Toast.makeText(getContext(), errorMessage,Toast.LENGTH_SHORT).show();
      }
  
      @Override
      public void onPerformUpdateAction() {
          callToPresenterToUpdateListOfCountriesOnInternetPresent(this.getContext());
      }
  
      private void initialize() {
          this.countriesEntireHolderRV = new RecyclerView(this.getContext());
          this.countriesListRecyclerViewAdapter = new CountriesListRecyclerViewAdapter(new ArrayList&lt;&gt;(),
                  LayoutInflater.from(this.getContext()), this.picasso);
  
          this.countriesEntireHolderRV.setLayoutManager(new LinearLayoutManager(this.getContext()));
          this.countriesEntireHolderRV
                  .addItemDecoration(new DividerItemDecoration(this.countriesEntireHolderRV.getContext()
                          ,DividerItemDecoration.VERTICAL));
          this.countriesEntireHolderRV.setAdapter(this.countriesListRecyclerViewAdapter);
          Log.d(TAG_LIST_FRAGMENT,"List Fragment init");
      }
  
      @Override
      public void onDestroyView() {
          super.onDestroyView();
          this.unbinder.unbind();
      }
  }  
  </code></pre>
  
  <hr>
  
  <pre><code>public class CountriesListRecyclerViewAdapter extends RecyclerView.Adapter&lt;CountriesListRecyclerViewAdapter.CountriesListViewHolder&gt;{
      private List&lt;CountriesFullEntity&gt; countriesFullEntityList;
      private final LayoutInflater layoutInflater;
      private final Picasso picasso;
      private CountriesListRVClickListener countriesListRVClickListener;
      private int currentPosition;
  
      CountriesListRecyclerViewAdapter(List&lt;CountriesFullEntity&gt; countriesFullEntityList, LayoutInflater layoutInflater, Picasso picasso) {
          this.countriesFullEntityList = countriesFullEntityList;
          this.layoutInflater = layoutInflater;
          this.picasso = picasso;
          this.currentPosition = 0;
      }
  
      @NonNull
      @Override
      public CountriesListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          return new CountriesListViewHolder(this.layoutInflater.inflate(R.layout.countries_list_layout,parent,false));
      }
  
      @Override
      public void onBindViewHolder(@NonNull CountriesListViewHolder holder, int position) {
          CountriesFullEntity countriesFullEntity = countriesFullEntityList.get(position);
          picasso.load(countriesFullEntity.getFlag()).into(holder.countryIcon);
          holder.nameOfCountry.setText(countriesFullEntity.getName());
      }
  
      @Override
      public int getItemCount() {
          return this.countriesFullEntityList.size();
      }
  
      void setItemClickListener(CountriesListRVClickListener itemClickListener) {
          this.countriesListRVClickListener = itemClickListener;
      }
  
      CountriesFullEntity getCountriesFullEntityAtPosition(int position) {
          return this.countriesFullEntityList.get(position);
      }
  
      void setCountriesFullEntityList(List&lt;CountriesFullEntity&gt; countriesFullEntityList) {
          this.countriesFullEntityList = countriesFullEntityList;
          notifyDataSetChanged();
      }
  
      int getCurrentPosition() {
          return currentPosition;
      }
  
      void setCurrentPosition(int currentPosition) {
          this.currentPosition = currentPosition;
      }
  
      class CountriesListViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
  
          @BindView(R.id.NameOfCountry)
          TextView nameOfCountry;
          @BindView(R.id.CountryIcon)
          ImageView countryIcon;
          CountriesListViewHolder(View itemView) {
              super(itemView);
          }
  
          @Override
          public void onClick(View v) {
              countriesListRVClickListener.onListItemClicked(v,getAdapterPosition());
          }
      }
  }  
  </code></pre>
  
  <hr>
  
  <hr>
  
  <p>My DAOs:  </p>
  
  <pre><code>@Dao
  public interface CountriesLocalDbDAO {
      @Query("SELECT * FROM Countries")
      Maybe&lt;List&lt;CountriesFullEntity&gt;&gt; getCountriesList();
  
      @Query("SELECT * FROM Countries WHERE name LIKE :countryName")
      Maybe&lt;CountriesFullEntity&gt; getCountryByName(String countryName);
  
      @Insert(onConflict = OnConflictStrategy.REPLACE)
      void insertAllCountries(List&lt;CountriesFullEntity&gt; countryList);
  
      @Insert(onConflict = OnConflictStrategy.REPLACE)
      void insertSingleCountry(CountriesFullEntity singleCountry);
  
      @Delete
      void deleteSingleCountry(CountriesFullEntity singleCountry);
  
      @Delete
      void endOfTheWorld(List&lt;CountriesFullEntity&gt; theWorld);
  }  
  </code></pre>
  
  <hr>
  
  <pre><code>public interface IRestServiceDataFetcher {
      @GET("all")
      Maybe&lt;List&lt;CountriesFullEntity&gt;&gt; getListOfCountriesData();
      @GET("name/{name}")
      Maybe&lt;CountriesFullEntity&gt; getParticularCountry(@Path("name") String name);
  }
  </code></pre>
  
  <hr>
  
  <hr>
  
  <p>My layouts:  </p>
  
  <p>ActivityMainLayout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout
  android:id="@+id/fragmentCanvas"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".ui.MainActivity"&gt;
      &lt;android.support.v4.widget.SwipeRefreshLayout
          android:id="@+id/MainActSwipeRefreshLayout"
          android:layout_height="20dp"
          android:layout_width="match_parent"&gt;
      &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>FragmentListLayout:  </p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context=".ui.countrieslist.CountriesListFrag"&gt;
  
      &lt;!-- TODO: Update blank fragment layout --&gt;
  
  
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/CountriesEntireHolderRV"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  &lt;/LinearLayout&gt;  
  </code></pre>
  
  <p>RecyclerViewViewHolderLayout:  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ImageView
          android:id="@+id/CountryIcon"
          android:layout_width="80dp"
          android:layout_height="80dp"
          android:layout_marginEnd="8dp"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginStart="8dp"
          android:layout_marginTop="8dp"
          android:contentDescription="@string/app_name"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:srcCompat="@drawable/ic_launcher_background" /&gt;
  
      &lt;TextView
          android:id="@+id/NameOfCountry"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginEnd="8dp"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginStart="8dp"
          android:layout_marginTop="8dp"
          android:text="@string/app_name"
          android:textSize="40sp"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toEndOf="@+id/CountryIcon"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <hr>
  
  <hr>
  
  <p>My app build.gradle:  </p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 27
      defaultConfig {
          applicationId "shankhadeepghoshal.org.countrieslistapp"
          minSdkVersion 14
          //noinspection OldTargetApi
          targetSdkVersion 27
          multiDexEnabled true
          versionCode 1
          versionName "1.0"
          vectorDrawables.useSupportLibrary = true
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          javaCompileOptions {
              annotationProcessorOptions {
                  includeCompileClasspath = true
              }
          }
          externalNativeBuild {
              cmake {
                  cppFlags "-std=c++14 -frtti -fexceptions"
              }
          }
          // multiDexEnabled true
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      externalNativeBuild {
          cmake {
              path "CMakeLists.txt"
          }
      }
      compileOptions {
          targetCompatibility JavaVersion.VERSION_1_8
          sourceCompatibility JavaVersion.VERSION_1_8
      }
      buildToolsVersion '27.0.3'
  }
  
  dependencies {
      implementation fileTree(include: ['*.jar'], dir: 'libs')
  
      implementation 'com.google.dagger:dagger:2.16'
      annotationProcessor 'com.google.dagger:dagger-compiler:2.16'
      implementation 'com.google.dagger:dagger-android:2.16'
      implementation 'com.google.dagger:dagger-android-support:2.16'
      annotationProcessor 'com.google.dagger:dagger-android-processor:2.16'
  
      implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
      implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
  
      implementation 'com.squareup.picasso:picasso:2.71828'
  
      implementation(
              [group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.6'],
              [group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.6'],
              [group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.6']
      )
  
      implementation 'com.squareup.retrofit2:retrofit:2.4.0'
      implementation 'com.squareup.retrofit2:converter-jackson:2.4.0'
      implementation 'com.squareup.retrofit2:adapter-java8:2.4.0'
      implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
      implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
  
      compileOnly 'org.projectlombok:lombok:1.18.2'
      annotationProcessor 'org.projectlombok:lombok:1.18.2'
  
      def room_version = "1.1.1"
      implementation "android.arch.persistence.room:runtime:$room_version"
      annotationProcessor "android.arch.persistence.room:compiler:$room_version"
      implementation "android.arch.persistence.room:rxjava2:$room_version"
      implementation "android.arch.persistence.room:guava:$room_version"
      testImplementation "android.arch.persistence.room:testing:$room_version"
  
      def lifecycle_version = "1.1.1"
      implementation "android.arch.lifecycle:extensions:$lifecycle_version"
      implementation "android.arch.lifecycle:runtime:$lifecycle_version"
      implementation "android.arch.lifecycle:common-java8:$lifecycle_version"
      implementation "android.arch.lifecycle:reactivestreams:$lifecycle_version"
      testImplementation "android.arch.core:core-testing:$lifecycle_version"
  
      implementation 'com.jakewharton:butterknife:8.8.1'
      annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
  
      implementation 'com.android.support:design:27.1.1'
      implementation 'com.android.support:appcompat-v7:27.1.1'
      implementation 'com.android.support.constraint:constraint-layout:1.1.2'
      implementation 'com.android.support:recyclerview-v7:27.1.1'
      implementation 'com.android.support:support-compat:27.1.1'
      implementation 'com.android.support:exifinterface:27.1.1'
      implementation 'com.android.support:multidex:1.0.3'
  
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test:rules:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  }
  </code></pre>
  
  <p>UPDATE:  </p>
  
  <p>I did what @Ben-P suggested in his answer. But now my RecycleViewAdapter is giving me errors.<br>
  I am getting an <code>IllegalArgumentException - Target must be null</code> on this line : <code>picasso.load(countriesFullEntity.getFlag()).into(holder.countryIcon);</code> in <code>onBindViewHolder(holder,position)</code></p>