如何从Android库构建AAR?

时间:2019-06-17 15:25:08

标签: android

我一直关注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'

根据文档,我现在应该只是:

  

项目窗口中选择库模块,然后单击构建>构建APK

这应该生成AAR文件。但是:

enter image description here

enter image description here

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

我在做什么错?我想走哪一步? AAR文件应该在哪里出现?

1 个答案:

答案 0 :(得分:1)

参考Create aar file in Android Studio,请尝试简单地Build > Rebuild project。 AAR文件应显示在~/Source/BluePlayer/bfsdk/build/outputs/aar

相关问题