Cordova添加平台失败,异常不支持major.minor版本52.0

时间:2017-01-09 06:36:00

标签: android node.js cordova

我正在尝试创建简单的cordova样本并按照以下步骤操作。当我添加平台时,它显示错误陈述"不支持的major.minor版本52.0" 。请帮忙。提前致谢。

步骤:

1.通过npm install -g cordova安装cordova 2.通过cordova创建一个app创建hello com.example.hello HelloWorld 3.试图通过cordova平台添加android平台来添加android平台

要解决此错误,请尝试安装android sdk 23,24和25 4.还检查了显示gradle安装的cordova要求。

我删除了平台android并试图再次添加它得到了同样的错误

错误:

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

节点版本:v4.4.7

Cordova版本:6.4.0

2 个答案:

答案 0 :(得分:2)

jdk更新为1.8,确保environment variable名为JAVA_HOME的{​​{1}}指向jdk 1.8的安装位置。

答案 1 :(得分:1)

我有同样的错误。请降级cordova版本:

npm uninstall -g cordova
npm install -g cordova@5.4.1