0

Problem (shaped like a 'V'):

We having a Java function a() - in a.java (top left of V)

a() calls another local function b() implemented via JNI - b.cpp (bottom of V)

b() creates an instance of java class C via JNI - defined in c.java (top right of V)

Nothing in a.java references c.java directly.


a.java ends up in a.class (.apk project)

b.cpp ends up in libB.so (.aar project)

c.java ends up in classes.jar (.aar project)


Question:

How is this run through with Androids 'd8' tool and positioned in an .apk file?


Solution Requirement:

Command line (not Android Studio)

Habor
  • 1

1 Answers1

0

Just used classes.jar together with a.class as sources when calling d8. It seems like d8 just puts everything it gets into the resulting classes.dex file - no reference or usage checking. libB.so lands in lib/ABI/libB.so and things just work.

Oh and NEVER forget to use extern "C" in front of your C/C++ functions or name mangling will prevent JNI to find anything in the library. ;)

Habor
  • 1