'Android AAR native library with header only prefab

I've been trying to create a Android AAR native library with header only prefab without success. We distribute other native libraries we build in Android Studio as prefabs in AARs and include them in other Android native applications. We'd like to do the same with a header-only library. We use Android Studio and cmake for the native part.

The docs clearly states:

Each dependency can expose at most one Prefab package, which comprises one or more modules. A Prefab module is a single library, which could be either a shared, static, or header only library.

One obvious workaround would be to build a dummy library and include it in the AAR so that prefabPublishing would work (it breaks when there no library file).

Another would perhaps be to add to the AAR (zip) a manually created prefab directory but I read somewhere that this could be a problem with signing.

Yet another would perhaps be to create the perfab directory structure manually, which would be ok, and included in verbatim in the AAR (if that would work?).

We use Android Studio 4.1.1 and gradle plugin 4.1 and create our AARs as described in the docs referenced below.

buildFeatures {
    prefabPublishing true
}

prefab {
    mylibrary {
        headers "src/main/cpp/include"
    }
}

https://developer.android.com/studio/build/native-dependencies?buildsystem=cmake

https://google.github.io/prefab/

Thanks, /Johan



Solution 1:[1]

Since Android Gradle Plugin 7.1 you can define headerOnly true.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ness