I’m developing a custom system app for AOSP using Kotlin and Jetpack compose.
I have added dependencies to ‘androidx.*’ and have compose and material 3 working.
android_app {
name: "MySystemApp",
srcs: ["java/**/*.kt"],
resource_dirs: ["res"],
manifest: "AndroidManifest.xml",
static_libs: [
"androidx.core_core"
]
}
Now I want to add a dependency upon external libraries, such as okhttp.
I understand that I somehow need to bundle okhttp (or any other dependency not already included in AOSP) with the AOSP build pipeline, and include it in the static_libs
section of Android.bp.
How do I add this external dependency to the build?
These docs from Google on Soong might help: https://ci.android.com/builds/submitted/11755031/linux/latest/raw/java.html#java_import
Here is an example, if you have JAR files downloaded for Jackson put the following in an Android.bp file with the JARs in a directory named libs
java_import {
name: "jackson-static-libs",
jars: [
"libs/jackson-core-2.13.3.jar",
"libs/jackson-databind-2.13.3.jar",
"libs/jackson-annotations-2.13.3.jar",
],
}
Now just add "jackson-static-libs"
to the static_libs
section.
Note that if you have an AAR file you can obtain the classes.jar inside it by unzipping the AAR and then rename it to something more useful.
OkHttp JARs can be found here these days: https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp/