tag:help.appveyor.com,2012-11-13:/discussions/problems/6459-xamarin-pcl-every-build-is-failing-msbuild-cannot-access-javalangobjectAppVeyor: Discussion 2017-04-18T02:05:56Ztag:help.appveyor.com,2012-11-13:Comment/423362982017-04-10T21:12:14Z2017-04-10T21:12:14Z[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)<div><p>Take a look at this issue for a solution at SO: <a href="https://github.com/appveyor/ci/issues/1486">https://github.com/appveyor/ci/issues/1486</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/423362982017-04-11T03:23:43Z2017-04-11T03:23:43Z[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)<div><p>@Feodor Thank you for your swift response.</p>
<p>I am using Xamarin Studio on OSx and i think I followed the same steps in here.</p>
<p>I went to Preferences (cmd+,) in XS -> Projects -> SDK Locations -> Set JDK to correct path<br>
<strong>References in uploaded images</strong></p>
<p>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. <em>At least, in my head I thought so</em>.<br>
No changes were made in any project file after this setup, but I made small changes and committed those changes. None was successful.</p>
<p>I do not know if there is something in my .gitignore that was not supposed to be there.</p>
<p><strong>My .gitignore</strong></p>
<pre>
<code>#Autosave files
*~<br><br>
<br>#build
[Oo]bj/
[Bb]in/
packages/
TestResults/<br><br>
<br>#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<br><br>
<br>#Mac bundle stuff
*.dmg
*.app<br><br>
<br>#resharper
*_Resharper.*
*.Resharper<br><br>
<br>#dotCover
*.dotCover<br><br>
<br>#VS sometimes writes these for no apparent reason
_UpgradeReport_Files
UpgradeLog.*<br><br>
<br>#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<br><br>
<br>#User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs.<br><br>
<br>#Installshield output folder
[Ee]xpress/</code>
</pre>
<p>Thank you for your time.</p></div>dan.b412tag:help.appveyor.com,2012-11-13:Comment/423362982017-04-17T11:26:44Z2017-04-17T11:26:44Z[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)<div><p>Any updates on this matter?</p></div>dan.b412tag:help.appveyor.com,2012-11-13:Comment/423362982017-04-17T20:38:37Z2017-04-17T20:38:37Z[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)<div><p>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.</p>
<p>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.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/423362982017-04-18T00:44:24Z2017-04-18T00:44:24Z[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)<div><p>Looks like we've found the source of this issue and the solution.</p>
<p>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 <code>C:\Program Files (x86)\Java\jdk1.6.0\\bin\javac.exe</code> was used during the build. That's why it "cannot" read java .class files compiled with more recent version.</p>
<p>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.</p>
<p>Setting <code>JAVA_HOME</code> or changing <code>PATH</code> environment variables wasn't forcing msbuild to use JDK 1.8, however, a hint was found in <a href="https://social.msdn.microsoft.com/Forums/en-US/d75f3f61-4656-40e8-9180-22bb2f7f82ac/uwp-build-definition-failing-in-vsts-with-error-msbuild-javacexe-error-cannot-access?forum=TFService">this thread</a> - setting up <code>JavaSdkDirectory</code> msbuild property (or environment variable with the same name).</p>
<p>Finally, adding this to <code>appveyor.yml</code> makes Android builds working again:</p>
<pre>
<code>environment:
JavaSdkDirectory: C:\Program Files (x86)\Java\jdk1.8.0</code>
</pre>
<p>@prajjwaldimri GitHubXamarin green build: <a href="https://ci.appveyor.com/project/FeodorFitsner/githubxamarin">https://ci.appveyor.com/project/FeodorFitsner/githubxamarin</a></p>
<p>@DaniloBarros 2017.1-Forum-Coordenadores-DEG green build: <a href="https://ci.appveyor.com/project/FeodorFitsner/2017-1-forum-coordenadores-deg">https://ci.appveyor.com/project/FeodorFitsner/2017-1-forum-coordena...</a></p>
<p>I guess most of developers have a single JDK installed on their machines, so the issue is not reproducible locally.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/423362982017-04-18T01:59:42Z2017-04-18T01:59:42Z[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)<div><p>Thank you very much!! This solved the problem for the build failing.</p>
<p>Thank you very much for your time.</p></div>dan.b412tag:help.appveyor.com,2012-11-13:Comment/423362982017-04-18T02:04:43Z2017-04-18T02:04:43Z[Xamarin PCL] Every build is failing (MSBUILD cannot access java.lang.Object)<div><p>You're welcome!</p></div>Feodor Fitsner