I am upgrading my existing Android Application Version(API-27) to API-28 using Cordova. I am using the Latest Version of Cordova, Gradle and 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. Below given the additional information,
Gradle-Wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
build.gradle: Tried this as well
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. This is explained in detail in this guide:
Upgrading Gradle for Cordova mobile apps in Windows
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.
Before jumping directly to latest gradle version, check compatibility with your Cordova environment. 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.
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. 2. I could have missed to add environmental variables, that is sorted out by installing the Android Studio and generating Build through that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.