Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fail with cordova-android 11 / AGP 7 #5

Closed
ath0mas opened this issue Jul 24, 2022 · 2 comments · Fixed by #6
Closed

Build fail with cordova-android 11 / AGP 7 #5

ath0mas opened this issue Jul 24, 2022 · 2 comments · Fixed by #6

Comments

@ath0mas
Copy link

ath0mas commented Jul 24, 2022

Expected Behaviour

cordova build should be successful with cordova-android 11 like with previous versions.

Confirmed to be OK with cordova-android 10.1.2.

Actual Behaviour

1: Task failed with an exception.
-----------
* Where:
Script 'C:\cdv-scanner\hello\platforms\android\@red-mobile\cordova-plugin-barcodescanner\hello-barcodescanner.gradle' line: 9

* What went wrong:
A problem occurred evaluating script.
> Could not find method compile() for arguments [{name=barcodescanner-release-2.1.7, ext=aar}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

cordova create hello com.example.hello HelloWorld
cd hello/
cordova platform add android@11.0.0
cordova plugin add @red-mobile/cordova-plugin-barcodescanner
cordova build

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Cordova CLI version and cordova platform version

cordova: 11.0.0
cordova-android: 11.0.0

Plugin version

cordova plugin version | grep @red-mobile/cordova-plugin-barcodescanner: 9.0.7

Sample Code that illustrates the problem

Logs taken while reproducing problem

While building with cordova-android 10.1.2, the following warning is shown:

WARNING:: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.

And yes, cordova-android 11 updated AGP 4.2.2 -> 7.1.0 -> 7.2.1 (see apache/cordova-android#1410 and apache/cordova-android#1446)!

@ath0mas ath0mas changed the title Build fail with cordova-android 11 / gradle 7 Build fail with cordova-android 11 / AGP 7 Jul 24, 2022
@eh2001
Copy link

eh2001 commented Oct 16, 2022

To those facing Android v11 with build error, edit the file "platforms/android/@red-mobile/cordova-plugin-barcodescanner/app-barcodescanner.gradle", replace the "compile" to "implementation", then build again.

compile(name:'barcodescanner-release-2.1.7', ext:'aar')

to

implementation(name:'barcodescanner-release-2.1.7', ext:'aar')

@ath0mas
Copy link
Author

ath0mas commented Oct 16, 2022

@eh2001 see my PR #6 on this

until review and merge, I published my own fork ns0m/cordova-plugin-ns0m-barcodescanner to npm cordova-plugin-ns0m-barcodescanner
and my v9.1.0 for the issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants