stevendesu
stevendesu

Reputation: 16841

How to build AAR from Android Library?

I've followed the official guide on creating Android libraries, but something doesn't quite seem to be working for me.

My project consists of two modules. One app module titled "app" and one library module titled "bfsdk". In my app's build.gradle file I include the library like so:

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'
}

Then in my library module my build.gradle specifies that it's a library in the first line:

apply plugin: 'com.android.library'

According to the documentation I should now just:

select the library module in the Project window and then click Build > Build APK

And this should build the AAR file. However:

enter image description here

enter image description here

When I click on this and wait for the whole build process to complete, I can't find an AAR file anywhere. This generates an APK file in ~/Source/BluePlayer/app/build/outputs/apk/android/release but there is no build directory in the ~/Source/BluePlayer/bfsdk folder.

What am I doing wrong? What step am I missing? Where is the AAR file supposed to appear?

Upvotes: 5

Views: 7192

Answers (2)

yoAlex5
yoAlex5

Reputation: 34461

Command line command will be executed under the hood

for example

./gradlew <moduleName>:assembleRelease

[Read more here]

Upvotes: 1

Mike Makhovyk
Mike Makhovyk

Reputation: 416

Referencing Create aar file in Android Studio, try to simply Build > Rebuild project. AAR file should appear in ~/Source/BluePlayer/bfsdk/build/outputs/aar

Upvotes: 9

Related Questions