如何从Android库构建AAR?

5

我已经按照创建Android库的官方指南,但是似乎有些地方不起作用。

我的项目包含两个模块。一个名为“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'

根据文档说明,我现在只需在“项目”窗口中选择库模块,然后单击“构建 > 构建APK”,即可构建AAR文件。然而:

enter image description here

enter image description here

当我点击它并等待整个构建过程完成时,我无法在任何地方找到AAR文件。这会在~/Source/BluePlayer/app/build/outputs/apk/android/release生成一个APK文件,但是在~/Source/BluePlayer/bfsdk文件夹中没有build目录。
我做错了什么?我漏掉了哪一步?AAR文件应该出现在哪里?
2个回答

9

1
使用“重建项目”(根据SO帖子)而不是“构建APK”(根据Google文档)可以解决问题。 - stevendesu

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接