I'm trying to build a custom apk into an AOSP build which uses some external libs like Firebase, Glide etc.

Studying the sample projects in AOSP and others like LineageOS, dependencies are added into Android.bp like so, for example:

build.gradle

dependencies {
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

Android.bp

android_app {
    ...
    static_libs: [
      "com.google.android.material_material"
      "androidx.recyclerview_recyclerview"
      "androidx-constraintlayout_constraintlayout"
    ],

    srcs: ["src/**/*.kt"],
    resource_dirs: ["res"],
}

For Firebase and Glide, I've tried adding to Android.bp like so:

android_app {
    ...
    static_libs: [
      "com.google.android.material_material",
      "androidx.recyclerview_recyclerview",
      "androidx-constraintlayout_constraintlayout",
      "com.google.firebase_firebase-core",
      "com.github.bumptech.glide_glide"
    ],

    srcs: ["src/**/*.kt"],
    resource_dirs: ["res"],
}

but this doesn't work, throw errors like so:

error: vendor/manufacturer/appname/Android.bp:1:1 "appname" depends on undefined module "com.google.firebase_firebase-core"
error: vendor/manufacturer/appname/Android.bp:1:1 "appname" depends on undefined module "com.github.bumptech.glide_glide"

Also noticed in Android.bp how the naming convention for constraintlayout is different than recyclerview, why is it not a . but a - and where's all this naming convention documented on how to should dependencies be added?

Where can I find more doc on how to add third party libs, any help pointers is much appreciated!

Build env:

Ubuntu 18.04
AOSP - 10_r39
1

There are 1 best solutions below

5
On

In AOSP, you can't use the "Gradle way" of just adding it into build.gradle, and having build tools fetch the module from a repository ( jCenter/ Maven Central etc.).
For AOSP you'll have to add those dependent modules in the build system yourself.
In your case, create two modules ( com.google.firebase_firebase-core and com.github.bumptech.glide_glide ), add Android.mk or Android.bp for them ( with the module name that you want, and then you can refer to them in your Android.bp.

For example, see how it's added for com.google.android.material_material :
https://cs.android.com/android/platform/superproject/+/master:prebuilts/sdk/current/extras/material-design-x/Android.bp