android - 如何在库模块中添加 .aar 依赖项?

标签 android android-studio gradle android-gradle-plugin build.gradle

我有一个库模块的 .aar 文件。
我想将它用作我其他项目的库模块中的库或依赖项。
我该怎么做?

我尝试了以下链接提供的选项:
http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/

仅当我在项目的应用程序模块中添加 .aar 引用时它才有效。但不能在库模块中工作。

谢谢。

最佳答案

按照此设置,您将能够将 .aar 依赖项添加到库模块

build.gradle(项目:....)

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        flatDir {
            dirs 'libs'
            dirs project(':library_module').file('libs')
        }
    }
}

build.gradle(模块:app)

dependencies {
    ...
    compile project(':library_module')
}

build.gradle(模块:library_module)

dependencies {
    ...
    compile(name:'aar_file_name', ext:'aar')
}

settings.gradle(项目设置)

include ':app', ':library_module'

关于android - 如何在库模块中添加 .aar 依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34765190/

相关文章:

android - PocketCasts 如何实现这种转换/效果?

android - E/EGL_emulation : tid 2633: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)

android - 如何在 Android Studio 中构建 'release' APK?

android-studio - 如何将flutter项目迁移到androidx:任务 ':app:preDebugBuild'执行失败。 > Android依赖项'androidx.versionedparcelable

android - 如何从另一个应用程序启动应用程序?

android 权限 READ_CALENDAR & WRITE_CALENDAR

Android Studio Junit 测试包 org.junit 不存在

android-studio - 将 Android Studio 更新到 3.3 后,Crashlytics 无法正常工作

android - 在平板电脑的 Android 应用程序中获取外部存储路径

java - 从编译中排除jar