Android build failed ionic : Error code 1

2019-05-29 10:13发布

I got the following error for the command ionic build android I don't have a clue what this error means. What should be done to rectify this error.I read that it happens if you dont have all the required platforms but I already installed almost all the versions of android along with latest build tools, support repositories and libraries.

-dex:
      [dex] input: C:\Users\XXX\Desktop\IonicProjects\Master\platfor
ms\android\ant-build\classes
      [dex] input: C:\Users\XXX\Desktop\IonicProjects\Master\platfor
ms\android\CordovaLib\ant-build\classes.jar
      [dex] Pre-Dexing C:\Users\XXX\Desktop\IonicProjects\Master\pla
tforms\android\CordovaLib\ant-build\classes.jar -> classes-564f85b75a48715c68c6f
85da336a58d.jar
       [dx] java.lang.UnsupportedClassVersionError: com/android/dx/command/Main
: Unsupported major.minor version 52.0
       [dx]     at java.lang.ClassLoader.defineClass1(Native Method)
       [dx]     at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
       [dx]     at java.security.SecureClassLoader.defineClass(SecureClassLoader
.java:142)
       [dx]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
       [dx]     at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
       [dx]     at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
       [dx]     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
       [dx]     at java.security.AccessController.doPrivileged(Native Method)
       [dx]     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
       [dx]     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
       [dx]     at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
       [dx]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

       [dx]     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
       [dx]     at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.j
ava:482)
       [dx] Exception in thread "main"
BUILD FAILED
D:\android-sdk\tools\ant\build.xml:888: The following error occurred while execu
ting this line:
D:\android-sdk\tools\ant\build.xml:890: The following error occurred while execu
ting this line:
D:\android-sdk\tools\ant\build.xml:902: The following error occurred while execu
ting this line:
D:\android-sdk\tools\ant\build.xml:283: null returned: 1

Total time: 13 seconds

C:\Users\XXX\Desktop\IonicProjects\Master\platforms\android\cordova\
node_modules\q\q.js:126
                    throw e;
                    ^
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,C:\Users\XXX\Desktop\IonicProjects\Master\platforms\android\build.xml,-Dout.dir=ant-buil
d,-Dgen.absolute.dir=ant-gen
ERROR running one or more of the platforms: Error: cmd: Command failed with exit
 code 1
You may not have the required environment or OS to run this project

Any sort of help or suggestion would be appreciated.

Thanks

1条回答
甜甜的少女心
2楼-- · 2019-05-29 10:47

Unsupported major.minor version 52.0 indicates that you need at least Java 8 to run the build, so try to update your JDK (Java class file number).

查看更多
登录 后发表回答