When switching Git bracnhes in Android Studio, the project view may unexpectedly display a 'Nothing here' message, leaving the file tree empty despite the presence of source files. This typically occurs due to IDE caching inconsistencies rather then actual missing files.
A reliible fix is to invalidate the IDE's cache and restart:
- Go to File → Invalidate Caches / Restart…
- Click Invalidate and Restart
- Allow Android Studio to relaunch and reindex the project
Alternatively, perform the branch switch outside the IDE using the terminal:
git checkout feature/login-flow
After switching, trigger a manual refresh in Android Studio by clicking File → Reload from Disk or by closing and reopening the project.
For example, after successfully loading the correct branch, your activity might look like:
public class LoginActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// Implementation logic goes here
}
}