So I guess the answer is a little late...but I have been trying to solve the same problem and have been searching for an answer for a long time. Tried a lot of different things and nothing really worked for me until I saw Pavel Poley's solution in https://stackoverflow.com/questions/29087882/android-studio-run-debug-configuration-error-module-not-specified
For me the project's API target specified in the build.gradle(:app) was 29 which is for android 10. But Android studio 4.2 by default only has API 30 which is for android 11.
To fix this go to tools->sdk-manager (or just click on the icon with a box and a blue down arrow in the tool bar) and install the sdk for the API target specified in your gradle file.