0

I try to generate headers file with javah. I have some issues but my main concern is that I can't generate the classpath argument of the command line : This argument should contain the classpath of my current android project (android.jar, my project and its dependencies).

commandLine  org.gradle.internal.jvm.Jvm.current().getExecutable('javah'), 
"-d", 'src/main/jni', 
"-classpath", classpath, "my.project.MainActivity"

actually, the classpath (variable classpath) is generated by hand. I would like to generate it using gradle dependencies instead, as gradle depency cache path are complicated to use (hard to compute by hand, ...)

It try to use sourceSets.main.runtimeClasspath and/or sourceSets.main.compileClasspath

def classpath = sourceSets.main.compileClasspath

but each time, gradle throw an error :

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find property 'compileClasspath' on source set main.

How can I generate my classpath variable using the classpath of my current gradle project ?

dwursteisen
  • 11,435
  • 2
  • 39
  • 36
  • Are you trying to auto generate JNI headers? Is this for a plugin? I would highly suggest writing C++ with JNI wrapper functions instead of he `JNI EXPORT` stuff that `javah` will generate. – Jared Burrows Jul 24 '15 at 20:24
  • I try to autogenerate JNI headers to a C/C++ lib. You're right, I can write by hand the header file. But have you any good pointer which explain how to write this file ? (method name convention ? type ? ) thanks. – dwursteisen Jul 24 '15 at 21:01
  • On how to write your C++ for the JNI? I would convert your JNI EXPORT code to C++ and use `JNI OnLoad`, see this: https://www.youtube.com/watch?v=YV0zSPVSL1E. This makes writing C++ simple. – Jared Burrows Jul 25 '15 at 01:25

0 Answers0