I've a really hard time to upgrade a deprecated plugin for scanning 1D barcode. My Old app was using phonegap-plugin-barcodescanner
But since I'm using Gradle 8.x there is compilation problems when I try to build:
1: Task failed with an exception. * Where: Script '.../src-cordova/platforms/android/phonegap-plugin-barcodescanner/my-old-app-barcodescanner.gradle' line: 9 * What went wrong: A problem occurred evaluating script. > 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. `gradle help --scan` doesn't brings more details
As far as I understand it, that plugin generates a .gradle
file which use deprecated directive such as compile()
which should be implementation()
when using Gradle 8:
repositories{ jcenter() flatDir{ dirs 'libs' } } dependencies { compile(name:'barcodescanner-release-2.1.5', ext:'aar') } android { packagingOptions { exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' } }
I tried to find an alternative plugin but a lot of them seems to depends on the package zxing-android-embedded
which require also a older version of Gradle (cordova-plugin-qrscanner):
> Could not find method compile() for arguments [com.journeyapps:zxing-android-embedded:3.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I tried a lot of plugin. I will not list here everything I tried but this is a maze of depcrated plugin where a user will tell you to use another one which is already deprecated.
Cordova-plugin-scanbot-sdk
seems to compile but it needs a license. Same thing for Dynamsoft Barcode Reader
.
So, Did you know a cordova plugin for scanning 1D barcode which is compatible with Gradle in 2022?
CodePudding user response:
You can try to use the Android X adapter plugin, it should transform the gradle file if I'm not mistaken.
CodePudding user response:
I solved my problem by applying manually this commit via a shell script before the cordova build: https://github.com/phonegap/phonegap-plugin-barcodescanner/pull/851/commits/beffcb1f229ee6259f4c75fc437b3a0a44e520d2
I don't really understand why this repos is archived and why the authors always refused to merge that PR.