ERROR using rdf4j in Punya$unsupportedFormat$0

I'm trying to use rdf4j in my external library. The code is built successfully but when I run my application I get the following errors:
System.err: at$unsupportedFormat$0(Unknown Source)
System.err: at$$Lambda$Rio$RwUjGrxduP5V8L47H1AptsOrfs.get(Unknown Source)
Does this mean that I use a version of rdf4j not supported by the Java system under Punya?
Which Java version does Punya hold?

1 Like

Is this for an extension ?

1 Like

Yes, it is

1 Like

Punya uses the same targets as App Inventor, and specifically it expects code that targets Java 6. It sounds like the version of the library you are using makes use of lambdas, which were added in Java 8. There is a utility called desugar that you might be able to use to convert the Java 8 bytecode to something compatible with older versions of Android.


Thanks @ewpatton, I thought it was Java 7. So, if I use a library compatible with Java7 it is normal to have problems, right?
That's because I removed problems related to lambdas downgrading my library to a version compatible with Java7, but it is still not working.
As far as you know is it possible to use rdf4j in punya? I downgraded to version 1.0 as it is compatible with Java 7 but I still get errors, so I'm trying to understand if desugaring will solve the problem or not.
Another problem could be that RDF4J relies on META-INF/services that are provided in the jar file after maven building process. But I think that the folder is not included in Android APKs. Is this correct? If so, how can I solve this problem?

Your best bet may be to patch rdf4j to work around the assumption regarding the META-INF folder. I think it cam work if you compile it in as a core Punya library but not in an extension. Do you have a branch somewhere that I could take a look?

1 Like

@ewpatton the problem, as expected, was linked to META-INF/services folder. I built an apk and then manually added required files and everything worked perfectly. So now, I need your help to solve this problem. You can look here:

What if we add needed files under punya/appinventor/components/src/META-INF/services folder?
Thanks in advance for your help

I'm trying to think of how I previously solved an issue like this but it has been many years. Jena stores its rules in a etc/ folder inside of its JAR, and those do successfully make the trip from the original JAR into the APK, and they are available for loading in the Reasoner component. Depending on exactly how rdf4j consumes these files in META-INF there might be an equivalent strategy.

  1. Does Jena automatically produce etc/ folder or files have been manually moved inside it? Because if this solves the problem I can try to rename the file to let it be included in the apk.

  2. What is punya/appinventor/components/src/META-INF/services folder meant for? Maybe it is not excluded by the apk file and if I move my files in it I would be able to solve the problem..

  3. I also see this option here punya/build.xml at master · mit-dig/punya · GitHub. Isn't there a configuration option to include this folder? You were talking about compiling rdf4j as a core library...

  4. Another possible solution I'm thinking about is putting META-INF/services files in another external jar (under a different name). The problem is that I don't know if then they are correctly linked

Sorry for this confused answer, but I'm trying to guess the solution and I really need your help

Those files are stored in the JAR file. You can see for yourself by looking at lib/jena/jena-2.10.0-android.jar.

That folder is included in the annotation processor library that is used during the compilation of the components. Those META-INF files are not included in anyway in the companion.

This is the implementation of my previous comment. These files do not go into the APK.

Here's where we end up handling the issue with Jena:

1 Like

First of all thanks for your time and all your answers.
Do you think that we can modify the file like here (punya/ at 971dceab58a68ed89a670b8a327aaa121d08d91b · mit-dig/punya · GitHub) in order to force apk builder to import the files I want?

Found this: java code examples | Tabnine

Tried this solution but this method passes through a FileFilter that excludes META-INF folder. It adds some files to the apk but not the ones I need. So the only solution is to force apkBuilder to add META-INF files with this: java code examples | Tabnine

What do you think? Will link you my code here asap

If you have a working patch we can review and merge it.