3

I am trying to create simple cordova sample and followed below step. When i am adding platform its showing the error stated "Unsupported major.minor version 52.0" . Please help on this. Thanks in advance.

Steps:

1.Installing cordova by npm install -g cordova 2. created a app by cordova create hello com.example.hello HelloWorld 3. Tried to add android platform by cordova platform add android

To resolve the error tried to install android sdk 23 ,24 and 25 4.also checked cordova requirements it showing gradle installed .

I removed platform android and tried to add it again got this same error

Error:

cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.example.hello
        Name: HelloWorld
        Activity: MainActivity
        Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android@6.0.0
Installing "cordova-plugin-whitelist" for android
ANDROID_HOME=C:\Users\Richa\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jre7
Subproject Path: CordovaLib

FAILURE: Build failed with an exception.

* Where:
Build file 'G:\Pogeyan\Projects\cordova test\sample\hello\platforms\android\build.gradle' line: 20

* What went wrong:
A problem occurred evaluating root project 'android'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.76 secs
Failed to install 'cordova-plugin-whitelist':Error: cmd: Command failed with exit code 1
    at ChildProcess.whenDone (G:\Pogeyan\Projects\cordova test\sample\hello\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:827:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Error: cmd: Command failed with exit code 1

Node Version : v4.4.7

Cordova Version : 6.4.0

selvan
  • 33
  • 4
  • Check your jdk version. If it is old one update it to 1.8 – Mable John Jan 09 '17 at 07:03
  • It's problem with `Cordova Version 6.4.0`, see answer of mine [here](http://stackoverflow.com/a/41427344/3840093), downgrade the version will help you. – Kirankumar Dafda Jan 09 '17 at 07:12
  • @selvan downgrading cordova version is not a good idea. Works for me with cordova 6.4.0 After upgrading cordova, create new project using cordova create command and try adding android platform – Gandhi Jan 09 '17 at 11:29

2 Answers2

2

Update jdk to 1.8, make sure that your environment variable named JAVA_HOME point to where your jdk 1.8 is installed.

Mable John
  • 4,518
  • 3
  • 22
  • 35
1

I had the same error. Please downgrade the cordova version:

npm uninstall -g cordova
npm install -g cordova@5.4.1
Hristo Eftimov
  • 13,845
  • 13
  • 50
  • 77