title: Synthetic import in kotlin not working
body: <p>In a <code>Fragment</code>, Kotlins synthetic import for layouts provided by <code>Anko</code> isn't working. I am trying to set the visibility of the views but it says the view is null. I have the following code.</p>
  
  <pre><code>class HistoryFragment : Fragment(), HistoryContract.view, LoaderManager.LoaderCallbacks&lt;List&lt;SongEntity&gt;&gt;{
  
      private lateinit var mPresenter : HistoryContract.Presenter
      private lateinit var adapter: HistoryAdapte
      private val loaderId : Int = 101
  
      override fun onLoadFinished(loader: Loader&lt;List&lt;SongEntity&gt;&gt;?, data: List&lt;SongEntity&gt;?) {
          hideLoadingIndicator()
  
          if (data == null) {
              showErrorView()
          } else {
              //update the adapter
              adapter.updateDataset(data)
          }
      }
  
      override fun onLoaderReset(loader: Loader&lt;List&lt;SongEntity&gt;&gt;?) {
      }
  
      override fun onCreateLoader(id: Int, args: Bundle?): Loader&lt;List&lt;SongEntity&gt;&gt; {
         showLoadingIndicator()
  
         return object : AsyncTaskLoader&lt;List&lt;SongEntity&gt;&gt;(activity!!.baseContext){
              override fun loadInBackground(): List&lt;SongEntity&gt;? {
                  return mPresenter.fetchSongs()
              }
          }
      }
  
      override fun showLoadingIndicator() {
          song_history_pv.visibility = View.VISIBLE
      }
  
      override fun hideLoadingIndicator() {
          song_history_pv.visibility = View.INVISIBLE
      }
  
      override fun showErrorView() {
          song_history_error_tv.visibility = View.VISIBLE
      }
  
      override fun hideErrorView() {
          song_history_error_tv.visibility = View.INVISIBLE
      }
  
      override fun setPresenter(presenter: HistoryContract.Presenter) {
          mPresenter = presenter
      }
  
      override fun showDiscoveredSongs(songs: List&lt;SongEntity&gt;) {
      }
  
      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
          val rootView = inflater.inflate(R.layout.fragment_song_history, container, false)
          loaderManager.initLoader(loaderId, null , this)
          songHistoryRv.layoutManager = LinearLayoutManager(context)
          songHistoryRv.adapter = HistoryAdapter {
              Toast.makeText(activity!!.baseContext, "${it.name}", Toast.LENGTH_SHORT).show()
          }
  
          return rootView
      }
  }
  </code></pre>
  
  <p>Now when I am setting the visibility of the progress view in the showLoadingIndicator function i am getting the error that the view is null.</p>
  
  <p><a href="https://i.stack.imgur.com/KPu7C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KPu7C.png" alt="This is the null error I am getting"></a></p>
  
  <p>Below is the layout file that I am using for the fragment</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;android.support.v7.widget.RecyclerView
          android:id="@+id/songHistoryRv"
          android:layout_width="0dp"
          android:layout_height="0dp"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintTop_toTopOf="parent"/&gt;
  
      &lt;ProgressBar
          android:id="@+id/song_history_pv"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="32dp"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"/&gt;
  
      &lt;TextView
          android:id="@+id/song_history_error_tv"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/song_history_error"
          android:visibility="invisible"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintBottom_toBottomOf="parent"/&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>import kotlinx.android.synthetic.main.fragment_song_history.* is the synthetic import that I am using.</p>
  
  <p>Please help me out on this. Am I missing something? I am new to kotlin.</p>