Theres this error occuring when converting images to pdf as follows;
```java
File file = new File(destinationDirectory, pdfName + ".pdf");
Log.e("PDF","Output to:"+file.toString());
FileOutputStream fileOutputStream = new FileOutputStream(file);
PdfWriter pdfWriter = PdfWriter.getInstance(document, fileOutputStream);
document.open();
System.out.println("CONVERTER START.....");
String[] splitImagFiles = imagFileSource.split(",");
for (String singleImage : splitImagFiles) {
Image image = Image.getInstance(singleImage);
document.setPageSize(image);
document.newPage();
image.setAbsolutePosition(0, 0);
document.add(image);
}
document.close();
**Tried adding**
ndk {
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
}
**but same error**
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp-tMMDQvGNIUp1-fffWZK0YQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-tMMDQvGNIUp1-fffWZK0YQ==/lib/arm64, /system/lib64, /system/product/lib64]]] couldn't find "liblcmm.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
at java.lang.System.loadLibrary(System.java:1667)
at org.apache.harmony.awt.Utils$2.run(Utils.java:44)
at java.security.AccessController.doPrivileged(AccessController.java:69)
at org.apache.harmony.awt.Utils.loadLibrary(Utils.java:42)
at org.apache.harmony.awt.gl.color.NativeCMM$1.run(NativeCMM.java:81)
at org.apache.harmony.awt.gl.color.NativeCMM$1.run(NativeCMM.java:79)
at java.security.AccessController.doPrivileged(AccessController.java:43)
at org.apache.harmony.awt.gl.color.NativeCMM.loadCMM(NativeCMM.java:78)
at org.apache.harmony.awt.gl.color.NativeCMM.<clinit>(NativeCMM.java:91)
at org.apache.harmony.awt.gl.color.NativeCMM.cmmGetProfileElementSize(Native Method)
at java.awt.color.ICC_Profile.getData(ICC_Profile.java:413)
at java.awt.color.ICC_Profile.getIntFromHeader(ICC_Profile.java:734)
at java.awt.color.ICC_Profile.getNumComponents(ICC_Profile.java:478)
at com.lowagie.text.pdf.PdfICCBased.<init>(PdfICCBased.java:81)
at com.lowagie.text.pdf.PdfWriter.addDirectImageSimple(PdfWriter.java:2996)
at com.lowagie.text.pdf.PdfWriter.addDirectImageSimple(PdfWriter.java:2938)
at com.lowagie.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1225)
at com.lowagie.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1121)
at com.lowagie.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1105)
at com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:2413)
at com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:747)
at com.lowagie.text.Document.add(Document.java:276)
at com.myapp.activity.InvoiceActivity.imagesToPdf(InvoiceActivity.java:349)
at com.myapp.activity.InvoiceActivity$6.onClick(InvoiceActivity.java:184)
at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
```
couldn't find "liblcmm.so"
Maybe you need liblcmm ?
If it is required for such a basic task, shouldnt it be included in library?
Have you read https://github.com/LibrePDF/OpenPDF/wiki/Android-support ?
And seen https://github.com/andob/android-awt ?
Pull requests welcome.
I don't know the issue to even try to fix it.
Opened issue here
https://github.com/andob/android-awt/issues/2
Same error here
@omkar-tenkale
This seems to be a dependency problem of apache harmony. The Stacktrace says that "liblcmm.so" could not be found. As I understand the code, this is a JNI part of apache harmony. So you probably have to bundle the native library to your App.
I have no idea how this is done, but I found this:
(German) https://wissensbasis.net/4198939/droidText-unstaisfiedLink-Fehler-beim-Erstellen-der-Image-Instanz
(English) https://stackoverflow.com/questions/24357687/how-to-include-so-library-in-android-studio
So I think this is not really a bug in OpenPDF.
Google play console is rising target sdk api level, so this will become an issue in no-time.
Also i saw on my phone (Google pixel 4xl android 11) that PNG file works as expected, JPG will not work.
Include this so library is not easy (at least for me) since i cannot find it anywhere...
I guess it's a native library but i am not sure about it.
Im having the same error:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/sign.pdf.document-K_ZkmDYfjbzQm4KKpsQLfA==/base.apk"],nativeLibraryDirectories=[/data/app/sign.pdf.document-K_ZkmDYfjbzQm4KKpsQLfA==/lib/arm64, /data/app/sign.pdf.document-K_ZkmDYfjbzQm4KKpsQLfA==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]] couldn't find "liblcmm.so"
Any solution?
The links by asturio didn't help?
Find "liblcmm.so" and include it into your project.
Unfortunately "Apache Harmony is retired at the Apache Software Foundation since Nov 16, 2011. "
So it might be difficult to find this file ...
I think @arnthom is right.
I'm closing this issue, as this is an Android-Runtime problem, as java.awt seems not to be available on android. And as long OpenPDF uses java.awt this can't be fixed.
I just checked that OpenPDF uses 290 imports of java.awt Classes, so using an alternative to AWT will be quite a big refactoring.
Feel free on dropping your ideas in gitter https://gitter.im/LibrePDF/OpenPDF
Ok, so OpenPDF does NOT support android anymore.
Sorry, but this is not an issue of OpenPDF. It's an issue of https://github.com/andob/android-awt. If you want to use OpenPDF on Android you need to use some library that provides AWT. I'm no Android programmer, so I can't explain this very good. But as you can see, there is no java.awt oder javax.swing packages on android, only java.awt.font.
https://developer.android.com/reference/packages.html
Please see these threads:
Feel free to help improve OpenPDF to be more Android compatible.
I agree this is not an OpenPDF bug, android move to OpenJDK removing Harmony, but you cannot say that OpenPDF is available on Android, this is not true.
Any new app must be target sdk 30 now and this will trigger this crash, so your android support is deprecated.
Thank you, I think it was never really supported. I'll correct the Wiki page. Can you tell, since which version of android it don't work anymore?
Harmony was deprecated since Nougat (api level 27), but i got this crash on android 30, but i may be wrong.
Thanks a lot for your input. I just corrected the Wiki-Page https://github.com/LibrePDF/OpenPDF/wiki/Android-support to reflect the reality. So to keep people to being frustrated. Feel free to correct the information of the page.
We are happy in receiving any code contribution to resolve that point.
I am trying to convert android-awt to use OpenJDK, will let you know if i succeed.
Thanks to andob now the bug seems to be fixed, he did find an old library repository and merged it on android-awt.
This is the new source code repository, by the way,
repositories {
maven { url "http://maven.andob.info/repository/open_source" }
}
implementation 'com.github.librepdf:openpdf:1.3.24'
implementation 'ro.andob.androidawt:androidawt:1.0.4'
Most helpful comment
Thanks to andob now the bug seems to be fixed, he did find an old library repository and merged it on android-awt.
This is the new source code repository, by the way,