1

I need to use Bouncy Castle with android (specifically for ECDHE). I included Bouncy Castle as a dependency in my gradle project file following: How to add Bouncy Castle algorithm to Android? I got the following error on compilation:

Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K.

Going through this link: https://developer.android.com/studio/build/multidex I found that multidex apps can have efficiency and security issues.

I then decided to manually add the needed classes from the library to my project as advised here: Using Bouncy Castle library causes massive increase in output .jar file size. This, however got too tedious.

Is there a better way to achieve what I need?

j.i.l.l
  • 11
  • 2
  • Doesn't your IDE provide some kind of automation for it? – Maarten Bodewes Mar 03 '22 at 23:29
  • @MaartenBodewes I am using Android Studio. I am not aware of any automation available for this use case. So far, I’ve tried to copy the class files that I need, but each of them in turn use several other classes. – j.i.l.l Mar 04 '22 at 04:32
  • I've tried to read through it, but I don't see security issues mentioned on the page you linked to, and for efficiency: I'd just test to see if it is an issue in the first place. Note that BC is a software only provider, and not a particularly well tested one IMHO. So if you can avoid using it altogether... You could maybe also try the FIPS provider if it fits your need, it would remove a lot of code I suppose. – Maarten Bodewes Mar 04 '22 at 09:14
  • @MaartenBodewes I decided to go with Bouncy castle enabling multidex for now. So far I don't see an efficiency issue except a slightly bigger apk size. I'll checkout the FIPS provider. Thanks! – j.i.l.l Mar 07 '22 at 05:24

0 Answers0