简体   繁体   English

Android Studio上的导入模块

[英]Import module on Android Studio

I've got a problem on library importation. 我在库导入方面遇到问题。 I followed these step : 我遵循了以下步骤:

  1. File / New / Import Module. 文件/新建/导入模块。
  2. Then I go to Project structure, Dependencies and "+". 然后,转到项目结构,依赖项和“ +”。 But there is Nothing to show. 但是没有什么可显示的。

Is somebody can help me ? 有人可以帮助我吗?

Screen : https://imgur.com/a/34mhw1N 屏幕: https : //imgur.com/a/34mhw1N

尝试:转到“ SDK管理器”->“ SDK工具”:查找支持存储库并下载它们,这可能有效

In order to add library module in your project you should follow the following steps: 为了在您的项目中添加库模块,您应该遵循以下步骤:

1) After adding library, open your project's build.gradle file and add implementation project(path: ':yourLibraryName') . 1)添加库之后,打开项目的build.gradle文件并添加implementation project(path: ':yourLibraryName')

2) Don't sync yet, now open your settings.gradle file and add your project with your library: include ':yourLibrayName', ':yourProject/ModuleName' . 2)还不同步,现在打开您的settings.gradle文件,并将您的项目添加到您的库中: include ':yourLibrayName', ':yourProject/ModuleName' Now sync. 现在同步。

3) After sync you will be able to use your library in your project. 3)同步后,您将可以在项目中使用您的库。

You need to add import module in gradle also 您还需要在gradle中添加导入模块

Try this 尝试这个

implementation project(path: ':yourLibName') 实施项目(路径:':yourLibName')

than sync it will show dependencies. 比同步它会显示依赖性。

Go to main menu -> File -> New -> Import Module. 转到主菜单->文件->新建->导入模块。 Then select the source code. 然后选择源代码。 Give module a name. 给模块起个名字。 (Android studio 3.3) (Android Studio 3.3)

Add following line to app build.gradle 将以下行添加到应用程序build.gradle

implementation project(':module_name')

Also in the settings.gradle file should have following line 同样在settings.gradle文件中应该有以下行

  include ':app'
  include ':module_name'

导入模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM