0

I have successfully imported BouncyCastle into my Android project and added the javamail for android packages to my project here.

I'm now having an issue when trying to sign a file, BouncyCastle try to access a class called DataFlavor, located into the java.awt.datatransfer package.

I've read on some posts that, in my case, the class is located into myjava.awt.datatransfer , in additional jar of Javamail for android

So I modified the sources of BouncyCastle jar to access this class, but unfortunately this didn't work, now it tells me that it

"cannot convert from ActivationDataFlavor to DataFlavor".

Does anyone knows how can I solve this issue ? Help will be appreciated!

Edit

Here is the complete stacktrace when app crashes

java.lang.NoClassDefFoundError: Failed resolution of: [Ljava/awt/datatransfer/DataFlavor; at org.bouncycastle.mail.smime.handlers.pkcs7_mime.(Unknown Source:16) at java.lang.Class.newInstance(Native Method) at javax.activation.MailcapCommandMap.getDataContentHandler(MailcapCommandMap.java:609) at javax.activation.MailcapCommandMap.createDataContentHandler(MailcapCommandMap.java:563) at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:626) at javax.activation.DataHandler.writeTo(DataHandler.java:329) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1692) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:996)

pocus
  • 51
  • 7
  • This has nothing to do with bouncycastle, which does not make reference to that class. – President James K. Polk Jan 30 '19 at 13:31
  • BouncyCastle calls this class when I use "SMIMESignedGenerator.generateEncapsulated()" – pocus Jan 30 '19 at 13:42
  • Post the complete stacktrace showing this. – President James K. Polk Jan 30 '19 at 13:43
  • I have updated my question, so you can see it there – pocus Jan 30 '19 at 13:55
  • Ah, the mail package. Are you using the spongycastle jars (com.magdag.spongycastle)? – President James K. Polk Jan 30 '19 at 14:05
  • No I don't, I'm using the bouncycastle jars only, I tried creating another project with spongycastle, but the class SMIMESignedGenerator exists only into bouncycastle jar – pocus Jan 30 '19 at 14:09
  • It sounds like you need the spongycastle jars rather than the bouncycastle jars. I don't know why the scmail jars aren't in maven, but perhaps you can pay rtyley to produce a scmail jar for 1.58. He accepts bitcoin as of a couple of years ago. – President James K. Polk Jan 30 '19 at 15:14
  • [Use the official JavaMail that has a special build for Android](https://stackoverflow.com/questions/6368704/java-lang-noclassdeffounderror-javax-activation-datahandler-in-android/37010429#37010429) – jmehrens Jan 30 '19 at 16:56
  • Hi @jmehrens , I've just tried using this javamail that you sent me, now I'm getting another error, at another place in the code, your help will be appreciated, here's what I het, an ExceptionInInitializerError with message java.lang.ArrayStoreException: javax.activation.ActivationDataFlavor cannot be stored in an array of type java.awt.datatransfer.DataFlavor[] – pocus Jan 31 '19 at 07:57

0 Answers0