Error when I build with PhoneGap BarcodeScanner (ionic-native)

Hello,
I updated Angular from 9 to 12 (step by step) but now, I have an error when I try to build for Android.
This error is related to Gradle and the plugin “phonegap-plugin-barcodescanner”:

Could not find method compile() for arguments [{name=barcodescanner-release-2.1.5, ext=aar}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

When I look in the Github repo of this plugin, I notice that this plugin is archived :confused:

1. Is anyone have the same issue? (maybe found a fix?)

2. Is there a way to solve it and keep the same plugin or should I use another plugin?

Thanks for your help & have a nice day!
Loïc

3 Likes

Unfortunately, it looks like this plugin uses the old way of including native Android libraries by using compile instead of implementation. Unless the original author publishes a new version it probably won’t work unless you downgrade your tools. You could change it locally to implementation instead of compile just so you can get your application building again.

I’d also recommend using the Capacitor Community Barcode Scanner if you can since it supports Capacitor 3 :grinning_face_with_smiling_eyes:

4 Likes

Hi Thomas,

Thank you for your reply :slight_smile:
Ok I will see to adapt this.

Kind regards

Hi again,

I changed the way to use this plugin in Android Studio > Project Structure > Dependencies and after this, it worked as expected (with the version 9 of Angular).

A temporary fix till I change the plugin :wink:

Thanks

3 Likes

Hi,
iam facing the same problem after upgrading to cordova-android 11. Can pls explain how did u make it work?

Hello @Vartex05,

As Thomas described above, the plugin uses the old method of including native Android libraries.

So the best option is to use the Capacitor plugin (which is up to date).
Otherwise, you can change manually (in Project Structure > Dependencies tab) the field “configuration” of the the dependency barcodescanner to switch from “compile” to “implementation”.

Kind regards,
Loïc

5 Likes

thx a lot it works :slight_smile:

1 Like

Where to find this option, please?

Hello @islamElbadawy,

You can see it in Android Studio in Project Structure > Dependencies tab. The field “configuration”.

configuration

Regards,
Loïc

1 Like

This fork includes the fix

You can add the plugin to your app with npm:
cordova plugin add @starley/barcodescanner-sdk31

1 Like