[英]Not able to build Cordova Project for Android using its Latest Version
I am upgrading my existing Android Application Version(API-27) to API-28 using Cordova.我正在使用 Cordova 将现有的 Android 应用程序版本(API-27)升级到 API-28。 I am using the Latest Version of Cordova, Gradle and Android.我正在使用最新版本的 Cordova、Gradle 和 Android。
Issue:问题:
A problem occurred evaluating project ':app'.
> Could not initialize class com.android.build.gradle.internal.crash.PluginCrashReporter
I tried different versions of Cordova and Gradle by downgrading/upgrading it but couldn't resolve this issue.我通过降级/升级尝试了不同版本的 Cordova 和 Gradle 但无法解决此问题。 Below given the additional information,下面给出了额外的信息,
Gradle-Wrapper.properties Gradle-Wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
build.gradle build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
build.gradle: Tried this as well build.gradle:也试过这个
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
}
Below given the detailed information about the issue.下面给出了有关该问题的详细信息。
Checking Java JDK and Android SDK versions
**ANDROID_SDK_ROOT=C:\Program Files\Android\sdk (recommended setting)
ANDROID_HOME=C:\Program Files\Android\sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app**
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\RandD\Mine\Chess\platforms\android\app\build.gradle' l
ine: 23
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not initialize class com.android.build.gradle.internal.crash.PluginCrash
Reporter
* 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 3s
D:\RandD\Mine\Chess\platforms\android\gradlew: Command failed with ex
it code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\RandD\Mine\Chess\platforms\android\app\build.gradle' l
ine: 23
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not initialize class com.android.build.gradle.internal.crash.PluginCrash
Reporter
* 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 3s
Picked up _JAVA_OPTIONS: -Xmx512M
Please highlight if i missing anything here.如果我在这里遗漏任何东西,请突出显示。 Thanks for your help.谢谢你的帮助。
From my experience (in Windows) it's not enough to edit build.gradle
to change the Gradle version , instead, try installing a different version globally.根据我的经验(在 Windows 中),仅编辑build.gradle
以更改Gradle 版本是不够的,而是尝试全局安装不同的版本。 This is explained in detail in this guide:本指南对此进行了详细说明:
Upgrading Gradle for Cordova mobile apps in Windows 为 Windows 中的 Cordova 移动应用程序升级 Gradle
Also, blindly switching to latest version of everything for Cordova apps is not the brightest idea, you should keep using the not-so-latest versions of everything, unless you are certain that you need latest version for a very specific reason.此外,盲目地切换到 Cordova 应用程序的所有内容的最新版本并不是最明智的主意,您应该继续使用所有内容的非最新版本,除非您确定出于非常特定的原因需要最新版本。
Before jumping directly to latest gradle version, check compatibility with your Cordova environment.在直接跳转到最新的 gradle 版本之前,请检查与您的 Cordova 环境的兼容性。 For safety reasons, I wont use anything newer than gradle 4.x on Cordova 7.1.0 alongside Visual Studio, otherwise some issues could be introduced.出于安全原因,我不会在 Cordova 7.1.0 和 Visual Studio 上使用比 gradle 4.x 更新的任何东西,否则可能会引入一些问题。
This issue has been resolved, below are the steps i followed.此问题已解决,以下是我遵循的步骤。
Take away Points : 1. There could be some problem in my environmental Variables (gradle, android SDK) that is causing issue in Generating the Build.要点: 1. 我的环境变量(gradle、android SDK)可能存在一些问题,导致生成构建出现问题。 2. I could have missed to add environmental variables, that is sorted out by installing the Android Studio and generating Build through that. 2.我可能错过了添加环境变量,这是通过安装Android Studio并通过它生成Build来解决的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.