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 -
app
module through Gradle In the root folder of your project, open the settings.gradle
file for editing.
Remove include ':app'
from the file.
On Android Studio, click on the File
Menu, and select Sync Project with Gradle files
.
After synchronisation, add include ':app'
back to the settings.gradle
file.
Re-run Sync Project with Gradle files
again.
没关系,我在settings.gradle中更改了名称并进行了同步,然后又将其改回并再次进行了同步,这一次它莫名其妙地起作用了。
尝试删除项目目录中的app.iml并重新启动android studio
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
.
I realized following line was missing in settings.gradle file
include ':app'
make sure you include ":app" module
在Android Studio 3.2.1上更新后,我遇到了相同的问题,必须重新导入项目,然后一切正常
I struggled with this because I'm developing a library, and every now and then want to run it as an application.
From app/build.gradle, check that you have apply plugin: 'com.android.application'
instead of apply plugin: 'com.android.library'
.
You should also have this in app/build.gradle:
defaultConfig { applicationId "com.your_company.your_application" ... }
Finally run Gradle sync.
If you can't find your settings.gradle file in your project directory
Add settings.gradle file
Add include ':app' inside the settings.gradle file
Rebuild or sync your project
Your app module should appear in your configuration file.
check your build.gradle
file and make sure that use apply plugin: 'com.android.application'
istead of apply plugin: 'com.android.library'
it worked for me
You have 3 ways:
Clean Project in Android Studio menu
Build -> Clean Project and use Build -> Rebuild
Remove all modal in settings.gradle
Remove all code in gradle.properties
Remove all code
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true
android.enableBuildCache=true
Sync gradle
I would like to add some more information while I was facing this issue:
Ref: Answer from @Eli:
- Cut line include '
:app
' from the file.- On Android Studio, click on the File Menu, and select Sync Project with Gradle files.
- After synchronisation, paste back line include ':app' to the settings.gradle file.
- Re-run Sync Project with Gradle files again.
So, let's follow the instruction and try to keep one thing in mind, that what is showing in your build configuration. Make sure you are seeing the name of your configuration app
like the image below:
If you are seeing anything else, then the steps mentioned by @Eli (the most accepted answer) will not work.
An alternative Solution If you have a different name on the Run/Debug Configurations window and the above process is not working, please change the config name to ' app
'
then -> hit Apply -> then Ok .
After that follow this:-
File -> Sync project with gradle files (if needed).
Now check the issue will be resolved hopefully. I have faced this issue and I think it might help others as well.
I was trying to open an old GitHub project with the latest android studio that's why got this error. I tried almost all the way that mentions in this post but none of them is work.
In my case, I update my Gradle version with my latest project, and the issue resolved. Use your latest Gradle version to resolve the issue.
Sometimes the project doesn't load your sdk version. so manually change the this in your build.gradle file module level to your own sdk version
now re-sync the your project.
我必须选择“使用模块的类路径:”下拉选项,然后选择我的模块。
Remove from app gradle this code
android{
defaultConfig.applicationId="com.storiebox"
}
We are currently recommending AS 3.3 for exercises.
These settings will work in the current 3.3 beta version with two small changes to your project:
In build.gradle (Project), change gradle version to 3.3.0-rc02
In menu go to File -> Project Structure. There you can change the gradle version to 4.10.0
None of the existing answers worked in my case (Android studio 3.5.0). I had to
in my case, when I added Fragment I git this error.
When I opened THe app build.gradle
I saw id("kotlin-android")
this plugin in plugins.
just remove it!
If all above solution doesn't work then do try this solution, because in my case none of the above solution were working. I too was facing this problem and after 5 hour of hard work I am able to tell you a solution. If you are cloning project using git the I would recommend you to directly clone project using android studio. It worked for me.
You can clean your project and and invalidate caches / restart. After that your project might be fixed.
This solution works for me.
Check your minsdkversion, compilesdkversion and targetsdkversion and ensure that you installed all those from Tools -> SDKManager in Android Studio.
eg if your targetsdkversion is 30 and minsdkversion is 28, ensure that you installed 28, 29, 30 sdks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.