6

I have a C++ module which builds to an aar file that contains a .so of the module. In order to use this in another project I need not only the .so but it's associated header files. I thought perhaps I could simply include the C++ header files in the .aar file but when importing an aar it doesn't appear that Android Studio unzips the .aar to make the header files visible.

How would I configure Android Studio/CMake to include header files in the .aar?

If I have a .aar file with header files, how can I make reference to the C++ header files when importing into Android Studio or do I need to unzip the .aar file instead of importing it into Android Studio?

Glenn
  • 1,996
  • 2
  • 24
  • 32
  • Related: *[Multiple Native Modules in Android Studio](https://stackoverflow.com/questions/41784862/multiple-native-modules-in-android-studio)* and *[Is it possible in Android Studio to build a native module with .so as output](https://stackoverflow.com/questions/38521846/is-it-possible-in-android-studio-to-build-a-native-module-with-so-as-output)* – Alex Cohn Nov 04 '17 at 08:14
  • 2
    I can build the .so and import the .aar file just fine but the .aar contains no C++ header files so I'm looking for a way to include the C++ header files in the aar with the hope I can then import the aar and reference them from C++ code in the main app. – Glenn Nov 05 '17 at 21:03
  • Look at this project https://github.com/skanti/Android-Manual-Build-Command-Line. I pretty much put everything in an archive `aar` file and ship it over to the device. – Armen Avetisyan Nov 14 '17 at 14:23

1 Answers1

0

this might help you click me!

Try to use AndroidNativeBundle plugin.

  • Edit your root build.gradle file, add classpath 'io.github.howardpang:androidNativeBundle:1.1.1' to the file
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        //Add androidNativeBundle dependency
        classpath "io.github.howardpang:androidNativeBundle:1.1.1"
    }
}
  • Apply plugin to your lib, add following line to your lib build.gradle
plugins {
    id 'com.android.library'
    id 'com.ydq.android.gradle.native-aar.export'
}
  • Specify header path that you want to export, add following code segment to your lib build.gradle;
nativeBundleExport {
    headerDir = "${project.projectDir}/native/export/header/path"
}
MemetGhini
  • 31
  • 5