Using "appinventor/lib/QRGenerator/core.jar" library in my extension?

Hi to All,

in this link:
https://github.com/mit-cml/appinventor-sources/tree/master/appinventor/lib/QRGenerator

there is core.jar file which is zxing barcode library, I am using extension-template to make extensions, how can I add the library in that link -and using that path- to my extension?

I haven't tried it but it seems like it would work. You'd need to copy the jar into the deps directory of the template and include it in the @UsesLibraries annotation to include it in your extension.

1 Like

@ewpatton
Thank you

I am already using this method and my extension compile seccussfully and works ok in Kodular, I imported the same extension to app-inventor but when I try to build apk I get this error:

yail compiler - dx execution failed

I use zxing core-3.1.1.jar library in my extension and maybe it is conflicting with "QRGenerator/core.jar" in app-inventor.

Hmm. So we do use it in the BarcodeScanner component, so this would only be an issue if you also included that component. Instead, what you can do is include the library in lib/deps, but don't add it to the @UsesLibraries annotation. Once you build the extension, you'll need to patch the component_build_infos.json file inside of the aix to include "QRGenerator.jar" in the list. This will cause the build system to use the version bundled in the buildserver rather than bundle it with your extension.

I followed your instructions and then I did add "QRGenerator.jar" to my extension "component_build_infos.json" file under libraries tag, now the apk build in Kodular give this error log:

Error

Kodular is unable to compile this project.
The compiler error output was
________Preparing application icon
________Creating animation xml
________Creating fragment xml
________Creating listview xml in res/layout/..
________Creating listview xml in res/layout-v21/..
________Creating xml in res/drawable/..
________Creating splash png in res/drawable/..
________Creating colors xml
________Creating styles xml
________Creating drawables xml v21
________Checking for firebase
________Creating provider_path xml
________Creating network_security_config xml
________Generating adaptive icon file
________Generating round adaptive icon file
________Generating adaptive icon background file
________Generating manifest file
________Attaching native libraries
________Attaching Android Archive (AAR) libraries
________Attaching component assets
________Invoking AAPT
AAPT time: 0.677 seconds
________Compiling source files
(compiling io/kodular/tasharud2018/vvv/Screen1.yail to io.kodular.tasharud2018.vvv.Screen1)
(compiling /tmp/runtime4911532256091377224.scm to com.google.youngandroid.runtime)
Kawa compile time: 1.115 seconds
________Invoking DX
DX time: 3.035 seconds
________Invoking ApkBuilder
com.android.sdklib.build.ApkCreationException: Failed to add /tmp/1598976163561_0.19056243266096695-0/youngandroidproject/../build/tmp/classes2.dex
YAIL compiler - ApkBuilder failed.

and in app-inventor when building apk same error:
yail compiler - dx excution failed

I use that jar in my Qr extension without any issue.
But one thing I would like to mention here is that the extension only works when you put a Bar Code Scanner component.

Another option that might work for both platforms is to use jarjar from the Android library to relocate the classes in QRGenerator.jar into a fresh package tied to your extension and include that repackaged jar in @UsesLibraries. This will prevent the dx error due to the name clash.

I didn't understand, please elaborate more.

thank you

Create a jar which contains only required classes and then use it in your extension.

i did that, but the error is same.

any help on this topic is appreciated.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.