简体   繁体   English

AndroidStudio - Gradle 中的模块依赖关系

[英]AndroidStudio - Module Dependencies in Gradle

I have a little problem compiling an android application using module dependencies in Android Studio.我在使用 Android Studio 中的模块依赖项编译 android 应用程序时遇到了一个小问题。

So, I want my application to use the library 'slidingmenu' (link here ).所以,我希望我的应用程序使用库“slidingmenu”(链接在这里)。

Here is my application tree:这是我的应用程序树:

  • Application应用
  • slidingmenu (source files)滑动菜单(源文件)
  • slidingmenu-maps-support (source files)滑动菜单地图支持(源文件)

Here is a link to see what I mean.这是一个链接,可以了解我的意思。

This is the error I'm getting.这是我得到的错误。

Gradle: A problem occurred configuring project ':Application'. Gradle:配置项目“:应用程序”时出现问题。

Failed to notify project evaluation listener.未能通知项目评估侦听器。

Configuration with name 'default' not found.未找到名为“default”的配置。

How do I specify a module dependency and where do I put the modules (inside Application or inside ApplicationProject?如何指定模块依赖项以及将模块放在哪里(在 Application 内还是在 ApplicationProject 内?

Thanks!谢谢!

EDIT 1: Never mind!编辑1:没关系! I got back to eclipse!我回到了日食! Android Studio is just not ready for a true project development. Android Studio 还没有为真正的项目开发做好准备。

You should put your library modules inside the Application Project.您应该将您的库模块放在应用程序项目中。 In order to specify a module dependency, simply:要指定模块依赖项,只需:

  1. Right click on Application -> Open Module Settings右键单击应用程序->打开模块设置
  2. Click on the '+' icon单击“+”图标
  3. Select the root directory for your library module you'd like to add.为您要添加的库模块选择根目录。
  4. Follow the prompts按照提示操作

Then, this module will show up in your project.然后,此模块将显示在您的项目中。 Then, you need to add it to Application as a library dependency.然后,您需要将其作为库依赖项添加到Application中。 Once again, in your Module Settings :再次,在您的模块设置中

  1. Select your Application module选择您的应用模块
  2. Select the Dependencies tab on the right选择右侧的依赖项选项卡
  3. Click the '+' icon on the bottom点击底部的“+”图标
  4. Select Module Dependency选择模块依赖
  5. Select your desired library module选择你想要的库模块

For people using the gradle way (explicitly rather than being generated by the IDE):对于使用 gradle 方式的人(明确而不是由 IDE 生成):

Add this to your app's build.gradle :将此添加到您的应用的build.gradle

dependencies {
    ....
    // other dependencies...
    implementation project(':module-name')
}

Add module as dependency添加模块作为依赖

  1. Add module into settings.gradle将模块添加到settings.gradle
include ':MyModule'

//Additionally you can specify  directory here
project(':MyModule').projectDir = new File('SomePath/HelloWorld')
  1. Add dependency into module将依赖添加到模块中
dependencies {
    implementation project(':MyModule')
}
  1. Sync Project同步项目

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

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