Android Studio-无模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25104392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:05:55  来源:igfitidea点击:

Android Studio-No Module

androidandroid-studio

提问by Android Developer

I am new to Android Studio.This is my project screenshot.My project builds successfully but when i run it only Build Successful is shown.enter image description here
By what I understand I think where build is written in the toolbar there should be my project name.When I go to Edit Configuration inside Module there is only one option that is No Module while I think my project name should be there.When I right click on my project and click on Make Module 'Copy of IBL2 eclipse' nothing happens.This project was running fine in eclipse.

我是 Android Studio 的新手。这是我的项目截图。我的项目构建成功,但是当我运行它时,只显示构建成功。在此处输入图片说明
根据我的理解,我认为在工具栏上写 build 的地方应该有我的项目名称。当我去编辑模块内的配置时,只有一个选项是无模块,而我认为我的项目名称应该在那里。当我正确时单击我的项目,然后单击制作模块“IBL2 eclipse 的副本”,什么也没有发生。这个项目在 eclipse 中运行良好。

回答by Ingo

Try first in Android Studio:

首先在 Android Studio 中尝试:

File -> Sync Project with Gradle Files

文件 -> 将项目与 Gradle 文件同步

回答by akshay bhange

In the "project" page on the top left corner in android studio.

在android studio左上角的“项目”页面中。

From dropdown goto Android >> Gradle Scripts >> Build Gradle(Module :app)

从下拉菜单转到 Android >> Gradle Scripts >> Build Gradle(Module :app)

make sure the first line of this file is like this.

确保这个文件的第一行是这样的。

apply plugin: 'com.android.application'

not like this

不是这样

apply plugin: 'com.android.library'

回答by vin

If you have imported the project, you may have to re-import it the proper way.
Steps :

如果您已导入该项目,则可能必须以正确的方式重新导入它。
脚步 :

  1. Close Android Studio. Take backup of the project from C:\Users\UserName\AndroidStudioProjects\YourProject to some other folder . Now delete the project.
  2. Launch Android Studio and click "Import Non-AndroidStudio Project (even if the project to be imported is an AndroidStudio project).
  3. Select only the root folder of the project to be imported. Set the destination directory. Keep all the options checked. AndroidStudio will prompt to make some changes, click Ok for all prompts.
  4. Now you can see the Module pre-defined at the top and you can launch the app to the emulator.

  1. 关闭 Android Studio。将项目从 C:\Users\UserName\AndroidStudioProjects\YourProject 备份到其他文件夹。现在删除项目。
  2. 启动 Android Studio 并单击“导入非 AndroidStudio 项目(即使要导入的项目是 AndroidStudio 项目)”。
  3. 只选择要导入的项目的根文件夹。设置目标目录。保持选中所有选项。AndroidStudio 会提示进行一些更改,所有提示点击确定。
  4. 现在您可以在顶部看到预定义的模块,您可以将应用程序启动到模拟器。

Tested on AndroidStudio version 1.0.1

在 AndroidStudio 1.0.1 版上测试

回答by edward perines

Other path is " tool menu-->android-->sync proyect with gradle File"

其他路径是“工具菜单-->android-->sync proyect with gradle File”

回答by Cody Maust

I was able to resolve this issue by performing a Gradle sync

我能够通过执行 Gradle 同步来解决这个问题

To do this:

去做这个:

  1. In project view, right click the root (in my example below, "JamsMusicPlayer"

  2. Click "Synchronize {ProjectName}"

  3. Once this completes, you should see a module in your "Run" dialog

  1. 在项目视图中,右键单击根目录(在我下面的示例中,“JamsMusicPlayer”

  2. 点击“同步{ProjectName}”

  3. 完成后,您应该会在“运行”对话框中看到一个模块

Gradle sync

摇篮同步

回答by A. Kali

For some reason, I was missing the settings.gradlefile.

出于某种原因,我丢失了settings.gradle文件。

  1. Create settings.gradleunder your root directory, and inside it:
  1. settings.gradle在您的根目录下创建,并在其中:
include ':app'

(assuming your app is indeed inside /appdirectory).

(假设您的应用程序确实在/app目录中)。

  1. Hit File-> Sync Project with Gradle Files.
  1. 点击File-> Sync Project with Gradle Files


After that everything worked out for me.


在那之后,一切都为我解决了。

回答by anKotliner

Go to Project setting enter image description here

进入项目设置 在此处输入图片说明

CHECKif the project setting is like this,if the module that you want is show in here enter image description here

检查项目设置是否是这样,如果你想要的模块在这里显示 在此处输入图片说明

IF the module that you want or "Module SDK" is not show or not correct.

如果您想要的模块或“模块 SDK”未显示或不正确。

then go to the module's build.gradlefile to check if the CompileSdkVersionhas installed in your computer.

然后转到模块的build.gradle文件检查您的计算机中是否安装了CompileSdkVersion

or modifier the CompileSdkVersion to the version that has been installed in your computer.

或将 CompileSdkVersion 修改为您计算机中已安装的版本。

In my case:I just installed sdk version 29 in my computer but in the module build.gradlefile ,I'm setting the CompilerSdkVersion28

就我而言:我刚刚在我的计算机上安装了 sdk 版本 29,但在模块build.gradle文件中,我设置了CompilerSdkVersion28

Both are not matched.

两者都不匹配

Modifier the build.gradle file CompilerSdkVersion29 which I installed in my computer

修改我电脑上安装的build.gradle文件CompilerSdkVersion29

It's working!!!

它的工作!

enter image description hereenter image description here

在此处输入图片说明在此处输入图片说明

回答by JesseBoyd

enter image description here

在此处输入图片说明

For those of you who are visual learners here is another place to look for the fix. I did indeed find that the underlined tag was pointing to "library" and a change to "application" and then updating gradle got my project running on the emulator.

对于那些视觉学习者来说,这里是另一个寻找解决方法的地方。我确实发现带下划线的标签指向“库”和“应用程序”的更改,然后更新 gradle 让我的项目在模拟器上运行。

回答by Shoaib Ahmed

Sometimes the following fix will work. Go to your build.gradle of your project and add google() into the repositories element and google() should be the at the top of all the repository.

有时以下修复会起作用。转到项目的 build.gradle 并将 google() 添加到 repositories 元素中,google() 应该位于所有存储库的顶部。

This is the sample of the repositories block. What you need to do is to add google() or if that exists already, take that to the top of all the line inside repositories

这是存储库块的示例。您需要做的是添加 google() 或者如果已经存在,请将其放在存储库中所有行的顶部

    repositories {
    google()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.google.com' }
}

回答by Logo

Check for the file gradle.propertiesin your project root folder. If not there, create a new file with the name / copy the file from other project.

检查gradle.properties项目根文件夹中的文件。如果没有,请使用名称创建一个新文件/从其他项目复制该文件。

Open and check both the build.gradle file and confirm you have have any error in those files.

打开并检查 build.gradle 文件并确认您在这些文件中有任何错误。

Then, Click on the Filemenu -> Sync project with Gradle Files.

然后,单击File菜单 -> Sync project with Gradle Files