Deactivating Xamarin.Android through Visual Studio Online build - xamarin.android

I am creating a build to build a Xamarin.Android project. I have a step to activate the license and another step to deactivate it. The deactivation fails with the error
Failed to deactivate license, only license activated by this task can be deactivated.
I think I am at an invalid state due to other problems I ran into before. How can I force a deactivation? Maybe a command line? I am using a Mac.

After running the build with Debug=true I noticed the Activate step was creating a License file under /Users/username/Library/MonoAndroid. Deleting that file solved the problem

Related

Cannot build Xamarin.Forms iOS project

I am trying to build our Xamarin.Forms application on Azure DevOps, but it fails for iOS with the following error:
Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.1.sdk/System/Library/Frameworks/Photos.framework/Headers/PHImageManager.h(18,2): error GB12A9FDE: "Photos requires C++11 or later" [/Users/runner/runners/2.159.2/work/1/s/My_MobileApp/My_MobileApp.iOS/My_MobileApp.iOS.csproj]
The app was originally created on VS 2017, then migrated to VS 2019. It worked, but stopped building yesterday for some reason.
What can I do to fix it?
OK, it is resolved:
We added a command line task prior to the xamarin.ios build task with the following inline script:
/bin/bash -c "echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'$(xcode.root);sudo xcode-select --switch $(xcode.root)/Contents/Developer"
and set a variable named xcode.root to /Applications/Xcode_10.3.app in order to override the faulty version of xcode on the build agent
This is kind of hacky, so once the issue is resolved upstream we will need to remove that override.

Fortify unable to load build session with ID when scanning iOS project

When scanning iOS project using Fortify, we are facing "unable to load build session with ID" issue.
What I did was, I opened the project by pointing to the folder of the source code. Then this error happened.
I am facing the same error while building a project written in C++. I am using VS 2017 and Fortify is throwing this error while running Analyze solution on .sln file.
Maybe this is occurring because of trying to translate and run -show-build-warnings in one command.
-show-build-warnings is a separate step, and will only work after translation, so try your command without that switch.
If it completes successfully, then you can run from VS dev cmdprompt sourceanalyzer -b -show-build-warnings to check for warnings.
You can check 'not show warning as errors' and reduce warning level to W3 and then build the solution in debug mode.
I resolved this by first doing the equivalent of a "make clean". If there are already executables there, sourceanalyzer make -s will no op and Fortify will not be able to work with them.

List command hangs in xcode

I am using the Jenkins Xcode plugin (https://wiki.jenkins-ci.org/display/JENKINS/Xcode+Plugin) to build an iOS application, however it hangs when running the following command on a project I have inherited from another developer:
$ /usr/bin/xcodebuild -list
It also hangs when I run this command manually from a terminal. Does anyone know what the cause may be? The warning displayed is also displayed on another project I have, but it does not hang in this case.
Running Xcode 6.1 on OS X 10.10
$ /usr/bin/xcodebuild -list
2014-11-12 04:47:21.234 xcodebuild[42642:1431240] [MT] DVTAssertions: Warning in /SourceCache/IDEFrameworks/IDEFrameworks-6604/IDEFoundation/SourceControl/Model/IDESourceControlManager.m:423
Details: Error Domain=com.apple.dt.IDESourceControlErrorDomain Code=-1 "Missing extension: public.vcs.subversion" UserInfo=0x7f9792309200 {NSLocalizedDescription=Missing extension: public.vcs.subversion}
Object: <IDESourceControlManager: 0x7f9792302860>
Method: -loadRepositories
Thread: <NSThread: 0x7f9790d2dbe0>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
Information about project "DOHSmokefree":
Targets:
DOHSmokefree
DOHSmokefreeTests
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
TLDR; My solution: Mark the schemes as shared in XCode if building them from the command line as a different user, or without ever opening XCode on the build machine.
I was having this same problem, intermittently on our CI server. I came across this question. The accepted answer with the problem being an issue and fixing the SVN version did not work for me as the SVN being used on the CI server was the default SVN and it was, as mentioned, working intermittently.
What I finally noticed is that, between a working version and a non-working version the schemes were not being listed. I had recently upgraded a library on the project and that got me to thinking about the schemes. After realizing that schemes are stored locally per user, unless shared, the fix for me was to go into the scheme manager and mark the schemes as shared.
The problem apparently being that the CI server user never actually opened the project in Xcode, thus causing the list command to hang because there were no available schemes for the user to build.
The times when it had intermittently worked were times after, logged in as the CI server user, I had opened the project in Xcode to test the build process, thus creating the necessary schemes. Wiping the CI server or refactoring/adding schemes would cause the build to break until the project was reopened in Xcode in desperation.
I had a similar issue when updating to Xcode 6.1 while using a newer version of subversion on the command line.
Disabling Source Control in Xcode Preferences should do the trick.
If that isn't an option you might try replacing the subversion implementation inside Xcode as I have done, using this technique: Use SVN 1.7 in XCode 4.3+
Basically that would be the following steps:
This assumes you already have SVN 1.7 installed to /opt/subversion, you can get it from WANdisco: http://www.wandisco.com/subversion/download#osx
Now open the Terminal and get an elevated shell using sudo -s.
Then, cd to inside the XCode.app package, to where the SVN binaries are.
Make a backup directory and move the old SVN files into it
bash-3.2# mkdir bup
bash-3.2# mv svn* bup/
Lastly, symbolically link the new files into the package:
bash-3.2# ln -s /opt/subversion/bin/svn* ./
That’s it!
I have the same problem on OS X 10.10 with XCode 6.4,just close XCode's Source Control to solved this issue:
run XCode
open Menu: XCode -> Preferences...
Click "Source Control" Tab and uncheck "Enable Source Control"

Missing ant and "code 8" errors when building multi-device hybrid application project

I have installed Multi Device Hybrid apps and when I'm building and debugging new project it showing these three errors
Error 1 executing command 'ant', make sure you have ant installed and added to your path.
Error 2 C:\Users\User\.cordova\lib\android\cordova\3.5.0\bin\create.bat: Command failed with exit code 8
Error 3 The command ""C:\Users\User\AppData\Roaming\npm\node_modules\vs-mda\vs-cli" prepare --platform iOS --configuration Debug --projectDir . --projectName "BlankCordovaApp2" --language "en-US"" exited with code 8.
But I have set all the paths and adt_home in environment variables and still it is showing this error what to do
Try the following to check and enable all required Environment Variables for Multi-Device Hybrid App.
Step 1:
Go to Visual Studio -> Debug Menu -> Multi-Device Hybrid Apps ->
Environment Variables Settings
Step 2:
Select Required Environment Variable from here as mentioned in
the attached screenshot
Make sure ANT_HOME path is set to correct location like %systemdrive%\apache-ant-1.9.3 and make sure ANT is installed at location ANT_HOME is pointing. Also make sure system path is set to %ANT_HOME%\bin. You can download ANT from here in case it is not already installed.
I found the solution to “code 8” errors when building multi-device hybrid application project. The error message you get is: Error 2 \bld\Debug\platforms\android\cordova\build.bat: Command failed with exit code 8 \MDAVSCLI 1 1
This happens if you play around with the config.xml in DevStudio GUI (not textually edit the file). If you change the LaunchMode property and change it back to default value which is "singleTop", a new entry will be added to config.xml:
<'preference name="AndroidLaunchMode" value="singletop" />
Just delete the entry, and your project compiles fine again. Quite a nasty bug in DevStudio

Error building a Release version when referencing a Web Service

If I create a New Mono Android application, then change the Active Config of the solution to Release, then right click and choose build, the application builds fine.
If I then add a web reference to http://soatest.parasoft.com/calculator.wsdl as per this tutorial, then if I build again I get the error:
Error 1 Could not load file or assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
C:\Users\Administrator\Documents\Visual Studio 2010\Projects\MonoAndroidApplication3\MonoAndroidApplication3\SGEN
If I change the Active config back to Debug then build, then the solution builds fine.
However, I cannot get the Release config to build at all when referencing any web service. This is causing me problems as I can't deploy a release version of my application.
I have tried using VS2010 and MonoDevelop 2.6 Beta 2, both give the same error.
I can't figure out why this is happening, but you can workaround it by going to the Build tab of your project properties and turning off "Generate serialization assembly".
Generate serialization assembly prevented you from building.
I got the NameResolutionFailure when selecting Release target because i didn't set the INTERNET permission in the application's options:
right click your project
select options
select the left item "Mono for Android Application"
set Required Permissions: "INTERNET" by checking the checkmark next to it.
It seems that this is active for debug builds since it's used to connect the debugger to the application.
You have to set this yourself in the Release build configuration.

Resources