1

I've built a fat jar of the tesseract basic example of 7.9 MB (see also this SO question). Now I want to shrink its size using ProGuard. Using this standard gradle task with the addition of keep 'class org.bytedeco.javacpp.** {*;}' and dontwarn 'org.bytedeco.javacpp.**' works just fine (7.6 MB jar size) but I get a lot of warnings when running the jar:

Warning: Loader.putMemberOffset(): java.lang.ClassNotFoundException: org.bytedeco.tesseract. ...  
Warning: Loader.putMemberOffset(): java.lang.ClassNotFoundException: org.bytedeco.leptonica. ...

(following this guide leads to the same result). I can prevent these warnings by keeping tesseract and leptonica too:

keep 'class org.bytedeco.tesseract.** {*;}'
keep 'class org.bytedeco.leptonica.** {*;}'

which results in a minimally larger jar (7.7 MB), but as the program seems to work OK with the warnings I was wondering if there's another way, e.g. by keeping not everything from org.bytedeco.

It's a really petty issue, but maybe there's an easy solution for it (the additional 0.1 MB is not a problem at all, just trying to get a little better understanding of javacpp, which is a really great library).

Stef
  • 28,728
  • 2
  • 24
  • 52
  • ProGuard doesn't support anything that uses JNI very well, so that's why we need to do a little bit of manual configurations in those cases. If you don't need the functionality that is getting removed though, there is no need to worry about those warnings. – Samuel Audet May 19 '20 at 02:58

0 Answers0