'How to fix Android Studio's "Apply Code Changes" not working?

I use the following code for testing:

while(true){
    Thread.sleep(5000);
    Log.d("debug", "Test A");
}

logcat shows "Test A" every 5 seconds. After I change it to "Test B":

Log.d("debug", "Test B");

I click the button "Apply Code Changes": enter image description here

Then I get the toast notification "Apply Code Changes succeeded": enter image description here

Unfortunately, logcat still shows "Test A". Could anyone shed some light on this?

Android Studio:

Android Studio Bumblebee | 2021.1.1 Patch 3
Build #AI-211.7628.21.2111.8309675, built on March 16, 2022
Runtime version: 11.0.11+9-b60-7590822 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Registry: external.system.auto.import.disabled=true, debugger.watches.in.variables=false
Non-Bundled Plugins: com.intellij.marketplace (211.7628.36), com.thoughtworks.gauge (211.6693.111), org.jetbrains.kotlin (211-1.6.21-release-334-AS7442.40), com.a

ndroid.aas (3.6.0), com.google.mad-scorecard (1.2), org.intellij.plugins.markdown (211.7142.37)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source