[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)

dan.b412's Avatar


10 Apr, 2017 08:14 PM


Recently every build I ran on AppVeyor started to fail, even when I rebuilt the commits that were passing.
My project link is the following https://ci.appveyor.com/project/DaniloBarros/2017-1-forum-coordenad...

The common error that I receive is the following:
Lines 4341 and 4340 from build log

MSBUILD : javac.exe error :  cannot access java.lang.Object [C:\projects\2017-1-forum-coordenadores-deg\ForumDEG\ForumDEG.Android\ForumDEG.Android.csproj]
MSBUILD : javac.exe error :  [C:\projects\2017-1-forum-coordenadores-deg\ForumDEG\ForumDEG.Android\ForumDEG.Android.csproj]

And another error that I saw, that I though was important was:

bad class file: java\lang\Object.class(java\lang:Object.class)
  class file has wrong version 52.0, should be 50.0
  Please remove or make sure it appears in the correct subdirectory of the classpath.
  public final class R {

Where I thought the JDK was the problem, and I changed the JAVA_HOME and PATH variables to point to jdk 1.8, 1.7 and 1.6, all x64 (Following the paths provided in https://www.appveyor.com/docs/build-environment/#java ). I also tried to put a nugget update inside the before_build: (only to result in another build error). All this without success.

The .yml file in my GitHub repository is the following ForumDEG appveyor.yml.

version: 1.0.{build}

# you can use {branch} name in version format too
# version: 1.0.{build}-{branch}

  - SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0\bin
  - java -version
  - echo %JDK_PATH%
  - echo %JAVA_HOME%
  - echo %PATH%

- ps: >-
    nuget restore ForumDEG.sln
# .\src\XLabs.Framework.sln

    project_name: 'ForumDEG'

# branches to build
  # whitelist
   - master
   - development

  # blacklist
  # except:
   # - gh-pages

# Do not build on tags (GitHub and BitBucket)
# skip_tags: true

# Start builds on tags only (GitHub and BitBucket)
# skip_non_tags: true

# Do not build feature branch with open Pull Requests
skip_branch_with_pr: false

# Maximum number of concurrent jobs for the project
max_jobs: 1

# Build worker image (VM template)
image: Visual Studio 2017

# scripts that are called at very beginning, before repo cloning
  - git config --global core.autocrlf input

# build Configuration, i.e. Debug, Release, etc.
configuration: Release

    # pushing a single file with environment variable in path and "Deployment name" specified
  - path: ForumDEG\bin\$(configuration)
    name: forumdeg

  - path: forumdeg.zip

  # pushing entire folder as a zip archive
  - path: logs


  # Email
  - provider: Email
      - [email blocked]
      - [email blocked]
      - [email blocked]
      - [email blocked]
    #  - '{{commitAuthorEmail}}'
    subject: 'Build {{status}}'                  # optional
    message: "{{message}}, {{commitId}}, ..."    # optional
    on_build_success: true|false
    on_build_failure: true|false
    on_build_status_changed: true|false

All solutions that I found in the community is telling to change the JDK version, however the way I tried to do so did not worked, and I can not found a solution for that.

Is this something that I can correct only configuring my .yml?

Thank you for your time and consideration.
Danilo Mendes

  1. Support Staff 1 Posted by Feodor Fitsner on 10 Apr, 2017 09:12 PM

    Feodor Fitsner's Avatar

    Take a look at this issue for a solution at SO: https://github.com/appveyor/ci/issues/1486

  2. 2 Posted by dan.b412 on 11 Apr, 2017 03:23 AM

    dan.b412's Avatar

    @Feodor Thank you for your swift response.

    I am using Xamarin Studio on OSx and i think I followed the same steps in here.

    I went to Preferences (cmd+,) in XS -> Projects -> SDK Locations -> Set JDK to correct path
    References in uploaded images

    The thing that I did not get, was how this is supposed to affect my build inside AppVeyor. Since, AppVeyor takes care of cloning my repository and running it inside AppVeyor. At least, in my head I thought so.
    No changes were made in any project file after this setup, but I made small changes and committed those changes. None was successful.

    I do not know if there is something in my .gitignore that was not supposed to be there.

    My .gitignore

    #Autosave files

    #build [Oo]bj/ [Bb]in/ packages/ TestResults/

    #globs Makefile.in *.DS_Store *.sln.cache *.suo *.cache *.pidb *.userprefs *.usertasks config.log config.make config.status aclocal.m4 install-sh autom4te.cache/ *.user *.tar.gz tarballs/ test-results/ Thumbs.db

    #Mac bundle stuff *.dmg *.app

    #resharper *_Resharper.* *.Resharper

    #dotCover *.dotCover

    #VS sometimes writes these for no apparent reason _UpgradeReport_Files UpgradeLog.*

    #NuGet Packages *.nupkg #The packages folder can be ignored because of Package Restore **/packages/* #except build/, which is used as an MSBuild target. !**/packages/build/ #Uncomment if necessary however generally it will be regenerated when needed !**/packages/repositories.config

    #User-specific files (MonoDevelop/Xamarin Studio) *.userprefs.

    #Installshield output folder [Ee]xpress/

    Thank you for your time.

  3. 3 Posted by dan.b412 on 17 Apr, 2017 11:26 AM

    dan.b412's Avatar

    Any updates on this matter?

  4. Support Staff 4 Posted by Feodor Fitsner on 17 Apr, 2017 08:38 PM

    Feodor Fitsner's Avatar

    Sorry, I didn't have a chance to check your project yet as I don't have a Mac with Xamarin Studio installed. True, that solution from SO thread is for Visual Studio users.

    Maybe you'd have a better way to fix it by asking on Xamarin support forums (or in that SO question)? You can share the solution then with the rest of us.

  5. Support Staff 5 Posted by Feodor Fitsner on 18 Apr, 2017 12:44 AM

    Feodor Fitsner's Avatar

    Looks like we've found the source of this issue and the solution.

    AppVeyor build workers have multiple versions of JDK installed: 1.6, 1.7 and 1.8. Seems like Android builds are now looking for Java in some different way and select Java with minimal version, in our case 1.6. You can noticed in a "bad" build log that C:\Program Files (x86)\Java\jdk1.6.0\\bin\javac.exe was used during the build. That's why it "cannot" read java .class files compiled with more recent version.

    In the past it was possible to "trick" Android builds by removing Java 1.6 keys from the Registry, but looks like now it just scans folders with JDKs installed. While RDPing into build worker I uninstalled JDK 1.6 and as a result javac.exe from JDK 1.7 was used during the build. Renaming/removing folders with JDK 1.6 and 1.7 also worked.

    Setting JAVA_HOME or changing PATH environment variables wasn't forcing msbuild to use JDK 1.8, however, a hint was found in this thread - setting up JavaSdkDirectory msbuild property (or environment variable with the same name).

    Finally, adding this to appveyor.yml makes Android builds working again:

      JavaSdkDirectory: C:\Program Files (x86)\Java\jdk1.8.0

    @prajjwaldimri GitHubXamarin green build: https://ci.appveyor.com/project/FeodorFitsner/githubxamarin

    @DaniloBarros 2017.1-Forum-Coordenadores-DEG green build: https://ci.appveyor.com/project/FeodorFitsner/2017-1-forum-coordena...

    I guess most of developers have a single JDK installed on their machines, so the issue is not reproducible locally.

  6. 6 Posted by dan.b412 on 18 Apr, 2017 01:59 AM

    dan.b412's Avatar

    Thank you very much!! This solved the problem for the build failing.

    Thank you very much for your time.

  7. Support Staff 7 Posted by Feodor Fitsner on 18 Apr, 2017 02:04 AM

    Feodor Fitsner's Avatar

    You're welcome!

  8. dan.b412 closed this discussion on 18 Apr, 2017 02:05 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac