Android 安卓工作室。导入后未指定模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23856529/
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 07:32:19  来源:igfitidea点击:

Android studio. Module not specified after import

androidimportandroid-studio

提问by Stepan Loginov

I use android studio. I import example project from official site

我使用安卓工作室。我从官方网站导入示例项目

http://developer.android.com/training/contacts-provider/retrieve-names.html

http://developer.android.com/training/contacts-provider/retrieve-names.html

When I try Run it I get Edit configurationwindow with Error: Module not specified.

当我尝试运行它时,我会得到Edit configuration带有Error: Module not specified.

I read this answer

我读了这个答案

https://stackoverflow.com/a/16625227/1864033

https://stackoverflow.com/a/16625227/1864033

and mark (in Project structure -> modules) my res/folder as resourcesfolder and sources folders as sources.

并将(在Project structure -> modules)我的res/文件夹标记为resources文件夹并将源文件夹标记为sources.

Problem still alive.

问题还活着。

Also Project structure -> modulessay that .gradleand buildis excluded folders.

Project structure -> modules.gradlebuild是排除文件夹。

What means "Module not specify" in android studio case?

在android studio案例中“模块未指定”是什么意思?

回答by Jürgen 'Kashban' Wahlmann

Probably you have to update your Android Studio Version and try again. I imported that sample without any issues and it's running fine on the Emulator.

可能您必须更新您的 Android Studio 版本并重试。我导入了该示例没有任何问题,它在模拟器上运行良好。

This is my import report from Android Studio:

这是我从 Android Studio 导入的报告:

ECLIPSE ANDROID PROJECT IMPORT SUMMARY

Replaced Jars with Dependencies: -------------------------------- The importer recognized the following .jar files as third party libraries and replaced them with Gradle dependencies instead. This has the advantage that more explicit version information is known, and the libraries can be updated automatically. However, it is possible that the .jar file in your project was of an older version than the dependency we picked, which could render the project not compileable. You can disable the jar replacement in the import wizard and try again:

android-support-v4.jar => com.android.support:support-v4:19.1.0

Moved Files: ------------ Android Gradle projects use a different directory structure than ADT Eclipse projects. Here's how the projects were restructured:

  • AndroidManifest.xml => app\src\main\AndroidManifest.xml
  • res\ => app\src\main\res\
  • src\ => app\src\main\java\

Next Steps: ----------- You can now build the project. The Gradle project needs network connectivity to download dependencies.

Bugs: ----- If for some reason your project does not build, and you determine that it is due to a bug or limitation of the Eclipse to Gradle importer, please file a bug at http://b.android.comwith category Component-Tools.

(This import summary is for your information only, and can be deleted after import once you are satisfied with the results.)

ECLIPSE ANDROID 项目导入摘要

使用依赖项替换了 Jars:-------------------------------- 导入程序将以下 .jar 文件识别为第三方库,并且将它们替换为 Gradle 依赖项。这样做的好处是可以知道更明确的版本信息,并且可以自动更新库。但是,您的项目中的 .jar 文件的版本可能比我们选择的依赖项的版本旧,这可能会使项目无法编译。您可以在导入向导中禁用 jar 替换并重试:

android-support-v4.jar => com.android.support:support-v4:19.1.0

移动的文件:------------ Android Gradle 项目使用与 ADT Eclipse 项目不同的目录结构。以下是项目的重组方式:

  • AndroidManifest.xml => app\src\main\AndroidManifest.xml
  • res\ => app\src\main\res\
  • src\ => app\src\main\java\

后续步骤: ----------- 您现在可以构建项目。Gradle 项目需要网络连接才能下载依赖项。

错误: ----- 如果由于某种原因您的项目没有构建,并且您确定这是由于 Eclipse 到 Gradle 导入程序的错误或限制,请在http://b.android.com提交错误与类别组件工具。

(此导入摘要仅供您参考,导入后您对结果满意后可将其删除。)

回答by Thirumoorthy

This sample project was not created for Android studio but for an eclipse project. So try to import this project to eclipse, and then export it to a Gradle project.If successful, you should now be able to import to android studio without any issue.

此示例项目不是为 Android Studio 创建的,而是为 Eclipse 项目创建的。所以尝试将这个项目导入eclipse,然后导出到Gradle项目。如果成功,你现在应该可以毫无问题地导入android studio了。

回答by naughty child

i hope this can help you Click the "File" ,then select "New Module",and the next is "Import Gradle Project",find the folder of your module,finish.

我希望这可以帮助您单击“文件”,然后选择“新建模块”,接下来是“导入 Gradle 项目”,找到您的模块的文件夹,完成。

回答by bebe

For my case, it was an existing Android studio project. What I did was to first close the project, and to open it, I clicked on "Open An Existing Android Studio Project" and it opened the project properly

就我而言,这是一个现有的 Android Studio 项目。我所做的是首先关闭项目,然后打开它,我点击“打开现有的Android Studio项目”并正确打开项目

回答by kamau wairegi

For my case I solved the same issue by just syncing the project with gradle files.

就我而言,我通过将项目与 gradle 文件同步来解决了同样的问题。