title: Android Studio 4 replaces kotlin class code to some garbage XML
body: <p>I am encountering a very strange issue with Android 4 with the following build version:</p>
  <pre><code>Android Studio 4.0
  Build #AI-193.6911.18.40.6514223, built on May 20, 2020
  Runtime version: 1.8.0_242-release-1644-b01 amd64
  VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  Windows 10 10.0
  GC: ParNew, ConcurrentMarkSweep
  Memory: 2014M
  Cores: 4
  Registry: ide.new.welcome.screen.force=true, debugger.watches.in.variables=false
  Non-Bundled Plugins: com.github.pedrovgs.androidwifiadb, com.layernet.plugin.adbwifi, drawable.importer.pluginId.7658.hack', wu.seal.tool.jsontokotlin
  </code></pre>
  <p>The issue is that while I am working or when I open a project. One or more Classes is replaced with some garbage xml and most of the times that class history is also not available. For example This class with code:</p>
  <pre><code>class LoginFragment : Fragment() {
  
      companion object {
          fun newInstance() = LoginFragment()
      }
  
      private lateinit var viewModel: LoginViewModel
  
      override fun onCreateView(
              inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
          return inflater.inflate(R.layout.login_fragment, container, false)
      }
  
      override fun onActivityCreated(savedInstanceState: Bundle?) {
          super.onActivityCreated(savedInstanceState)
          viewModel = ViewModelProvider(this).get(LoginViewModel::class.java)
          viewModel.init(this)
          init()
      }
  
      private fun init() {
  
          val onFocusListener = View.OnFocusChangeListener { v, _ -&gt;
              if (v.isFocused) {
                  v.scaleX = 1.1f
                  v.scaleY = 1.1f
                  // v.translateX = offsetLeft
                  // v.translateн = offsetTop
              } else {
                  v.scaleX = 1f
                  v.scaleY = 1f
                  //  v.translateX = offsetLeft
                  // v.translateн = offsetTop
              }
          }
  
          userNameEdit.onFocusChangeListener = onFocusListener
          passwordEdit.onFocusChangeListener = onFocusListener
          loginBtn.onFocusChangeListener = onFocusListener
  
          userNameEdit.requestFocus()
          loginBtn.setOnClickListener {
              when {
                  userNameEdit.text.isNullOrEmpty() -&gt; {
                      userNameEdit.error = &quot;Username cannot be empty&quot;
                  }
  
                  passwordEdit.text.isNullOrEmpty() -&gt; {
                      passwordEdit.error = &quot;Password cannot be empty&quot;
                  }
                  else -&gt; {
                      viewModel.loginUser(userNameEdit.text.toString(), passwordEdit.text.toString())
                  }
              }
  
          }
      }
  
      private fun LoginViewModel.init(lifecycleOwner: LifecycleOwner) {
          isLoading.observe(lifecycleOwner, Observer {
              if (it) {
                  loginBtn.visibility = View.INVISIBLE
                  loginProgress.visibility = View.VISIBLE
              } else {
                  loginBtn.visibility = View.VISIBLE
                  loginProgress.visibility = View.INVISIBLE
              }
          })
  
  
          loginResponse.observe(lifecycleOwner, Observer {
              val userName = it.userName.value!!
              val password = it.password.value!!
              val loginResponse = it.loginResponse.value!!
  
              SharedPrefs.setUserName(requireContext(), userName)
              SharedPrefs.setPassword(requireContext(), password)
  
              val userEntity = DatabaseOp.getUser(userName)
  
              if (userEntity == null) {
                  //for new user
                  val newUser = UserEntity(null, loginResponse.full_name, loginResponse.profile_pic_url, password, loginResponse.phone_number, userName)
                  DatabaseOp.addUser(newUser)
  
              } else {
                  // for old user
                  userEntity.fullName = loginResponse.full_name
                  userEntity.imageUrl = loginResponse.profile_pic_url
                  userEntity.password = password
                  userEntity.phoneNumber = loginResponse.phone_number
                  userEntity.userName = userName
  
                  DatabaseOp.updateUser(userEntity)
              }
              (requireActivity() as MainActivity).changeFragment(SOURCE_HOME)
          })
  
          apiFailure.observe(lifecycleOwner, Observer {
              Toast.makeText(requireContext(), it, Toast.LENGTH_SHORT).show()
          })
  
      }
  
  
      interface ChangeFragment {
          fun changeFragment(source: String)
      }
  
  }
  </code></pre>
  <p>This class was replaced with this garbage xml:</p>
  <pre><code>����   4$ 'com/invotyx/syncdownloadphotos/R$string  java/lang/Object   com/invotyx/syncdownloadphotos/R  string abc_action_bar_home_description I   abc_action_bar_up_description  $abc_action_menu_overflow_description  abc_action_mode_done  !abc_activity_chooser_view_see_all  *abc_activitychooserview_choose_application  abc_capital_off  abc_capital_on  abc_menu_alt_shortcut_label  abc_menu_ctrl_shortcut_label      abc_menu_delete_shortcut_label 
   abc_menu_enter_shortcut_label   abc_menu_function_shortcut_label  abc_menu_meta_shortcut_label 
   abc_menu_shift_shortcut_label  abc_menu_space_shortcut_label  abc_menu_sym_shortcut_label  abc_prepend_shortcut_label  abc_search_hint   abc_searchview_description_clear   abc_searchview_description_query  !abc_searchview_description_search  !abc_searchview_description_submit   abc_searchview_description_voice  &quot;abc_shareactionprovider_share_with  .abc_shareactionprovider_share_with_application   abc_toolbar_collapse_description  app_name  appbar_scrolling_view_behavior  bottom_sheet_behavior  browse_title  buy_1  buy_2   %character_counter_content_description ! 0character_counter_overflowed_content_description &quot; character_counter_pattern #   chip_text $ 'clear_text_end_icon_content_description % 
  dismiss_error &amp; error_fragment ' error_fragment_message ( error_icon_content_description ) )exposed_dropdown_menu_content_description * !fab_transformation_scrim_behavior + !fab_transformation_sheet_behavior ,   grid_view - hello_blank_fragment . #hide_bottom_view_on_scroll_behavior / icon_content_description 0 *lb_control_display_fast_forward_multiplier 1 $lb_control_display_rewind_multiplier 2 lb_guidedaction_continue_title 3 lb_guidedaction_finish_title 4 lb_media_player_error 5 %lb_navigation_menu_contentDescription 6  lb_onboarding_accessibility_next 7 lb_onboarding_get_started 8 .lb_playback_controls_closed_captioning_disable 9 -lb_playback_controls_closed_captioning_enable : !lb_playback_controls_fast_forward ; ,lb_playback_controls_fast_forward_multiplier &lt; lb_playback_controls_hidden = )lb_playback_controls_high_quality_disable &gt; (lb_playback_controls_high_quality_enable ? !lb_playback_controls_more_actions @ lb_playback_controls_pause A 'lb_playback_controls_picture_in_picture B lb_playback_controls_play C lb_playback_controls_repeat_all D  lb_playback_controls_repeat_none E lb_playback_controls_repeat_one F lb_playback_controls_rewind G &amp;lb_playback_controls_rewind_multiplier H lb_playback_controls_shown I $lb_playback_controls_shuffle_disable J #lb_playback_controls_shuffle_enable K lb_playback_controls_skip_next L &quot;lb_playback_controls_skip_previous M lb_playback_controls_thumb_down N 'lb_playback_controls_thumb_down_outline O lb_playback_controls_thumb_up P %lb_playback_controls_thumb_up_outline Q lb_playback_time_separator R lb_search_bar_hint S lb_search_bar_hint_speech T lb_search_bar_hint_with_title U $lb_search_bar_hint_with_title_speech V movie W )mtrl_badge_numberless_content_description X (mtrl_chip_close_icon_content_description Y #mtrl_exceed_max_badge_number_suffix Z mtrl_picker_a11y_next_month [ mtrl_picker_a11y_prev_month \ &amp;mtrl_picker_announce_current_selection ] mtrl_picker_cancel ^ mtrl_picker_confirm _  mtrl_picker_date_header_selected ` mtrl_picker_date_header_title a &quot;mtrl_picker_date_header_unselected b %mtrl_picker_day_of_week_column_header c mtrl_picker_invalid_format d &quot;mtrl_picker_invalid_format_example e mtrl_picker_invalid_format_use f mtrl_picker_invalid_range g (mtrl_picker_navigate_to_year_description h mtrl_picker_out_of_range i *mtrl_picker_range_header_only_end_selected j ,mtrl_picker_range_header_only_start_selected k !mtrl_picker_range_header_selected l mtrl_picker_range_header_title m #mtrl_picker_range_header_unselected n mtrl_picker_save o  mtrl_picker_text_input_date_hint p *mtrl_picker_text_input_date_range_end_hint q ,mtrl_picker_text_input_date_range_start_hint r mtrl_picker_text_input_day_abbr s !mtrl_picker_text_input_month_abbr t  mtrl_picker_text_input_year_abbr u )mtrl_picker_toggle_to_calendar_input_mode v #mtrl_picker_toggle_to_day_selection w %mtrl_picker_toggle_to_text_input_mode x $mtrl_picker_toggle_to_year_selection y not_set z orb_search_action { #password_toggle_content_description | path_password_eye } %path_password_eye_mask_strike_through ~ path_password_eye_mask_visible  path_password_strike_through � personal_settings � related_movies � rent_1 � rent_2 � search_menu_title � %status_bar_notification_info_overflow � 
  stories_title � watch_trailer_1 � watch_trailer_2 � &lt;init&gt; ()V
    
  ConstantValue Code InnerClasses 1     �      !    
       !      
       !           !           !           !           !           !           !           !           !           !       !   !    &quot;  #   !    $  %   !    &amp;  '   !    (  )   !    *  +   !    ,  -   !    .  /   !    0  1   !    2  3   !    4  5   !    6  7   !    8  9   !    :  ;   !    &lt;  =   !    &gt;  ?   !    @  A   !    B  C   !    D  E   !    F  G   !    H  I   !    J  K   !    L  M   !    N  O   !    P  Q   !    R  S   !    T  U   !    V  W   !    X  Y   !    Z  [   !    \  ]   !    ^  _   !    `  a   !    b  c   !    d  e   !    f  g   !    h  i   !    j  k   !    l  m   !    n  o   !    p  q   !    r  s   !    t  u   !    v  w   !    x  y   !    z  {   !    |  }   !    ~      !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !    �  �   !           !       !       !       !           !   
       !    
       !       !       !       !       !       !       !       !      &quot;        *� �     #   
       
  </code></pre>
  <p>It is happening since 2 days on different projects. This issue has occurred since I started development of Android TV app. If any one has any solution, it would be great. Please don't suggest to revert my Android Studio to 3.6</p>
  <p><strong>EDIT</strong>
  I have just checked that the xml files are replaced with the some class' imports.</p>