0

I have a project that I am trying to implement Continuous Integration using Visual Studio Team Services. I have a build definition for the Android Project but the build is failing. The app builds and runs in visual studio no problem.

The error I get is this:

Error : java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

I have installed the latest jdk and I have deleted the build tools for api 24. and the same result it builds in Visual Studio but not when the CI build occurs.

Does anyone have any idea as to a solution? Any feedback would be great

Thanks

EDIT:

HERE IS THE JDK LOCATION: enter image description here

JH_Dev
  • 426
  • 7
  • 26
  • Do you have jdk 1.8 and is it properly set? – MadDeveloper Oct 29 '16 at 07:36
  • @MadDeveloper I have i.8 installed I just used the default setup didn't do anything special to it. should I? – JH_Dev Oct 29 '16 at 12:31
  • I don't think you have to uninstall build tools for api 24 - that has been solved - http://stackoverflow.com/questions/36457947/java-lang-unsupportedclassversion-error-in-xamarin-studio/36585636#36585636 – MadDeveloper Oct 30 '16 at 09:34
  • Still no joy again the project builds fine in visual studio but when I check in my code the Continuous integration build fails – JH_Dev Oct 30 '16 at 16:24

2 Answers2

0

Here is what xamarin technical bulletin says,

Possible ways to fix:

  • Update to Java JDK 8, and then make sure that JDK 8 is selected in the Xamarin preferences: Visual Studio: Tools > Options > Xamarin > Android Settings > Java Development Kit Location. Xamarin Studio (on Mac): Xamarin Studio > Preferences > Projects > SDK Locations > Android > Java SDK (JDK).
  • Or uninstall all Android SDK Build-tools versions 24 and higher via the Android SDK manager.
  • Or set the AndroidSdkBuildToolsVersion MSBuild property to an earlier version. For example, if you also have version 23.0.3 installed, you could add the following line within the top element in the Android project .csproj file: 23.0.3

You should probably check that the same versions of Java/Android SDK Build-tools are used on your build server as well as on your development machine

oldbam
  • 2,397
  • 1
  • 16
  • 24
0

Check the correct jdk installed. You can find dx.bat file in the sdk tools directory.

In my case, my sdk tools version is 25.0.2. So, my directory structure looks like below.

enter image description here

Check the correct version installed by adding echo message at last line of the file.

echo "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%

Usually, the system variable must be JAVA_HOME like mine as follows.

JAVA_HOME=C:\DEV\COMP\Java\jdk1.8.0_111

You can see the same error message when executing dx command with jdk 1.8, if you have some classes compiled by 1.7.

enter image description here

So, my opinion is you'd better choose old version of sdk tools than yours with jdk 1.7.

tommybee
  • 2,409
  • 1
  • 20
  • 23