Как исправить проблему «build.gradle» в проекте Cordova?

#cordova #build.gradle #ionic4 #apache-cordova

#кордова #build.gradle #ionic4 #apache-cordova

Вопрос:

 $ cordova build android --debug
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=E:andoidSDK (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:projelerohsmobileplatformsandroidCordovaLibbuild.gradle' line: 41

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> Failed to apply plugin [id 'com.github.dcendents.android-maven']
   > Configuration with name 'testImplementation' not found.

* 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 2s
> Configure project :CordovaLib

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings
C:projelerohsmobileplatformsandroidgradlew: Command failed with exit code 1 Error output:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:projelerohsmobileplatformsandroidCordovaLibbuild.gradle' line: 41

* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> Failed to apply plugin [id 'com.github.dcendents.android-maven']
   > Configuration with name 'testImplementation' not found.

* 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 2s
[ERROR] An error occurred while running subprocess cordova.

        cordova build android --debug exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
  

Комментарии:

1. Моя ОС — Windows 10.

Ответ №1:

Я изменил

путь к классу ‘com.android.tools.build:gradle:3.3.0’

Для

путь к классу ‘com.android.tools.build:gradle:3.0.1’

в файле /platforms/android/build.gradle. Моя проблема решена.

Комментарии:

1. Правильный ответ, это тоже помогло мне, когда я столкнулся с такой же проблемой. Спасибо.

Ответ №2:

файл build.gradle в replace :

 dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
}
  

после запуска :
ionic cordova build android —prod —release

Ответ №3:

Измените язык вашей системы на английский
Эта проблема связана с Android Studio 3.3
Если вы используете одноязычную ОС, вы можете изменить версию, выполнив
файл> Структура проекта> Проект -> Версия плагина Android = 3.2

Комментарии:

1. где вы это делаете? Какое приложение?

2. Я думаю, что он использует Android Studio IDE

Ответ №4:

В моем случае это было вызвано неправильным значением в вашем config.xml для Android-versionCode

Это значение должно быть только числовым.