【问题标题】:How to build AAR from Android Library?如何从 Android 库构建 AAR?
【发布时间】:2019-06-17 15:25:08
【问题描述】:

我关注了the official guide on creating Android libraries,但似乎有些东西不太适合我。

我的项目由两个模块组成。一个名为“app”的应用程序模块和一个名为“bfsdk”的库模块。在我的应用程序的 build.gradle 文件中,我像这样包含库:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(path: ':bfsdk')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

然后在我的库模块中,build.gradle 在第一行指定它是一个库:

apply plugin: 'com.android.library'

根据文档,我现在应该:

Project窗口中选择库模块,然后点击Build > Build APK

这应该构建 AAR 文件。然而:

当我单击它并等待整个构建过程完成时,我在任何地方都找不到 AAR 文件。这会在~/Source/BluePlayer/app/build/outputs/apk/android/release 中生成一个APK 文件,但~/Source/BluePlayer/bfsdk 文件夹中没有build 目录。

我做错了什么?我错过了什么步骤? AAR 文件应该出现在哪里?

【问题讨论】:

    标签: android


    【解决方案1】:

    引用Create aar file in Android Studio,尝试简单的Build > Rebuild project。 AAR 文件应该出现在~/Source/BluePlayer/bfsdk/build/outputs/aar

    【讨论】:

    • 使用 Rebuild Project(根据 SO 帖子)而不是 Build APK(根据 Google 文档)有效
    猜你喜欢
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 2017-10-07
    相关资源
    最近更新 更多