2

I am trying to compile native code using the experimental plugin. This code references header files which reside at a different location In the good old Android.mk days I would simply add LOCAL_C_INCLUDES and point it to the location of the header files.

But how do I do it via the gradle build script when I have no Android.mk? What is the equivalent for LOCAL_C_INCLUDES in gradle?

I tried

android.ndk { 
   moduleName = "mymodule"
   cppFlags.add("-I${file("C:\\Android\\JNI\\inc")}".toString()) 
}

but it did not work.

The header files can not be found: "my_file.h No such file or directory."

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Student
  • 43
  • 6

1 Answers1

2

What exactly are you trying to do? If you need to add header files to your mymodule library, you can modify the:

sources {
    main {
        jni {
            exportedHeaders {
                srcDir "src/main/headers"
            }
        }
    }
}

property.

But if you want to add an external include folder you'll need to provide more info. In general, it's not as simple as adding some external directory. You're cross compiling, remember. Are those headers the same for every platform? If so you're fine but if you need to link against the libraries you have to include the path to them in the linker arguments. You should checkout the experimental android native gradle plugin.

dcow
  • 7,765
  • 3
  • 45
  • 65
  • - I cannot seem to get the exportedHeaders working, could you please take a look at http://stackoverflow.com/questions/37147657/exportedheaders-dsl-does-not-seem-to-include-the-headers – Harkish May 10 '16 at 20:27