1

ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=C:\Users\gacna\AppData\Local\Android\Sdk (DEPRECATED) (node:5840) [DEP0128] DeprecationWarning: Invalid 'main' field in 'C:\Pandora\PROD\Mobile\WebApp.Cordova\node_modules\objectorarray\package.json' of 'dist/index.js'. Please either fix that or report it to the module author (Use node --trace-deprecation ... to show where the warning was created) Using Android SDK: C:\Users\gacna\AppData\Local\Android\Sdk Reading build config file: C:\Pandora\PROD\Mobile\WebApp.Cordova\build.json Subproject Path: CordovaLib Subproject Path: app

FAILURE: Build failed with an exception.

  • Where: Build file 'C:\Pandora\PROD\Mobile\WebApp.Cordova\platforms\android\app\build.gradle' line: 62

  • What went wrong: A problem occurred evaluating project ':app'.

Could not find method compile() for arguments [com.android.support:support-v4:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings Command failed with exit code 1: C:\Pandora\PROD\Mobile\WebApp.Cordova\platforms\android\gradlew cdvBuildDebug -b C:\Pandora\PROD\Mobile\WebApp.Cordova\platforms\android\build.gradle

Trying to run cordova run on android studio.

Gabriel
  • 11
  • 1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Dec 26 '22 at 23:41

1 Answers1

1

You need to replace compile with implementation. This issue occurs from cordova-android 11 and up. For me, it was the qr-scanner plugin that gave this error. You can patch it with patch package.

cordova-android-11 docs (this issue is referenced in the comments): https://cordova.apache.org/announcements/2022/07/12/cordova-android-release-11.0.0.html

patch package: https://www.npmjs.com/package/patch-package

Mister_CK
  • 668
  • 3
  • 13
  • I have encountered the same problem, I can't use any qr code scanner plugin with android 11. Maybe could you share how did you manage to fix it? I've been working with this for 2 days and haven't found a solution yet. – KoreLewi Feb 15 '23 at 09:28
  • 1
    I am not on the same project anymore, so I don't have the exact patch I made. But the only thing you have to do is replace `compile` with `implementation` wherever it is present, I believe it is only this file. https://github.com/bitpay/cordova-plugin-qrscanner/blob/master/src/android/qrscanner.gradle. If you build your app with that, it should work. If you do this inside the plugin in your node_modules folder, you can run patch package to create a patch that automatically gets applied whenever you install plugins (i.e. the plugins folder is created from your node_modules) – Mister_CK Feb 15 '23 at 17:25