android-sourcewireguardandroid-soong

Building an AOSP app with maven dependency


I am building an AOSP system app which depends upon the Wireguard tunnel library.

The Android.bp file is as follows:

android_app {
    name: "VPN",
    srcs: [
        "java/**/*.kt",
    ],
    resource_dirs: [
        "res"
    ],
    manifest: "AndroidManifest.xml",
}

How do I add a dependency on an external dependency?

I have tried downloading the AAR file from Maven and including is in the Android.bp file, then including it in static_libs on the android_app.

android_library_import {
    name: "wireguard-lib",
    aars: [
        "libs/tunnel-1.0.20230706.aar",
    ],
    sdk_version: "current",
    extract_jni: true,
}

Solution

  • Try the following:

    android_library_import {
        name: "wireguard-lib",
        aars: ["libs/tunnel-1.0.20230706.aar"],
    }
    
    android_app {
        name: "VPN",
        srcs: [
            "java/**/*.kt",
        ],
        resource_dirs: [
            "res"
        ],
        manifest: "AndroidManifest.xml",
        static_libs: ["wireguard-lib"],
    }