Android Studio Run/Debug configuration error: Module not specified
I am getting a 'Module not specified' error in my run config. I have no module showing in the drop down yet I can see my module no probs. The issue came about when I refactored my module name, changed the settings.gradle to new name.
Now when I go to project structure and select my module nothing shows in the screen, not even an error.
I'm not 100% sure, but the icon beside my module looks like a folder with a cup and not a folder with a phone.
My exact steps -
- Open in Android view
- Refactor directory name
- refactor module name
- change settings.gradle contents: name to new name
Solution 1:
Resync your project gradle files to add the app
module through Gradle
-
In the root folder of your project, open the
settings.gradle
file for editing. -
Cut line
include ':app'
from the file. -
On Android Studio, click on the
File
Menu, and selectSync Project with Gradle files
. -
After synchronisation, paste back line
include ':app'
to thesettings.gradle
file. -
Re-run
Sync Project with Gradle files
again.
Solution 2:
never mind, i changed the name in settings.gradle and synced and then changed it back and synced again and it inexplicably worked this time.
Solution 3:
Try to delete the app.iml in your project directory and restart android studio
Solution 4:
This issue also may happen when you just installed new Android studio and importing some project, in the new Android studio only the latest sdk is downloaded(for example currently the latest is 30) and if your project target sdk
is 29 you will not see your module
in run configuring
dialog.
So download the sdk that your app is targeted, then run Sync project with gradle files
.
Solution 5:
You have 3 ways:
- Clean Project in Android Studio menu
Build -> Clean Project and use Build -> Rebuild
- Remove all the modules in settings.gradle
- Open settings.gradle project
- Remove include ':app' and other modules
- Sync gradle
- Add include ':app' and other modules
- Sync gradle again
- Remove all code in gradle.properties
-
Open gradle.properties project
-
Remove all code
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true
android.enableBuildCache=true
-
Sync gradle
-
Add code again
-
Sync gradle again