How to programmatically retrieve the version information of Visual Studio for Mac? - xamarin

I want to retrieve the version information of Visual Studio for Mac during a build job of a Xamarin App. The goal is to include them as debug information in the binary. Is there a way to get the version number of Visual Studio, Xamarin.iOS and Xamarin.Android programmatically or with a command statement using msbuild?
Manually one can get the information under:
Visual Studio > About Visual Studio > Show Details > Copy Information [button]
=== Visual Studio Community 2017 for Mac ===
Version 7.6.11 (build 9)
Installation UUID: f7e73512-ad50-4119-a682-e2cf05031ad6
Runtime:
Mono 5.12.0.309 (2018-02/39d89a335c8) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)
Package version: 512000309
=== NuGet ===
Version: 4.3.1.4445
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.2
2.1.1
2.0.5
2.0.4
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
2.1.302
2.1.301
2.1.4
2.1.3
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.3
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Xamarin.Android ===
Version: 9.0.0.20 (Visual Studio Community)
Android SDK: /Users/christopher/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.1
SDK Build Tools Version: 27.0.3
Java SDK: /usr
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Apple Developer Tools ===
Xcode 10.1 (14460.46)
Build 10B61
=== Xamarin.Mac ===
Version: 5.0.0.0 (Visual Studio Community)
Hash: b40230c0
Branch:
Build date: 2018-09-27 11:41:37-0400
=== Xamarin.iOS ===
Version: 12.2.1.10 (Visual Studio Community)
Hash: f2a05edd
Branch: d15-9
Build date: 2018-10-31 18:55:57-0400
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 706110009
Git revision: d7cd66f5e3acd3d46ba0b94a0c935378f828bde0
Build date: 2018-10-31 17:17:12+00
Build branch: release-7.6
Xamarin extensions: bc9b985bfcb480b04a208a6d4045adc443a07857
=== Operating System ===
Mac OS X 10.13.6
Darwin 17.7.0 Darwin Kernel Version 17.7.0
Thu Jun 21 22:53:14 PDT 2018
root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

Here is a simplified version of one of my Global.cs that contains version information obtained during the build:
Global template
namespace SomeVersionInfo
{
public static class Globals
{
public const string VS4MVersion = "SushiVS4MVersion";
public const string XiOSVersion = "SushiXiOSVersion";
public const string XDroidVersion = "SushiXDroidVersion";
}
}
macOS Bash file
VS4MVersion=`/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Applications/Visual\ Studio\ \(Preview\).app/Contents/Info.plist`
XDroidVersion=$(< /Library/Frameworks/Xamarin.Android.framework/Versions/Current/version)
XiOSVersion=$(< /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/Version)
sed -e 's/SushiVS4MVersion/'"$VS4MVersion"'/g' Global.template > Global.cs
sed -i '' -e "s/SushiXiOSVersion/$XiOSVersion/g" Global.cs
sed -i '' -e "s/SushiXDroidVersion/$XDroidVersion/g" Global.cs
Results:
namespace SomeVersionInfo
{
public static class Globals
{
public const string VS4MVersion = "8.0.0.869";
public const string XDroidVersion = "9.1.5";
public const string XiOSVersion = "12.2.1.13";
}
}

Some of the other version information can be retrieved with:
VisualStudio=`/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Applications/Visual\ Studio.app/Contents/Info.plist`
echo $VisualStudio
NetCoreSdk=`dotnet --version`
echo $NetCoreSdk
MsBuild=`msbuild /version | sed -n 4p`
echo $MsBuild
XamarinProfiler=`/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' /Applications/Xamarin\ Profiler.app/Contents/Info.plist`
echo $XamarinProfiler
XDroid=$(< /Library/Frameworks/Xamarin.Android.framework/Versions/Current/version)
echo $XDroid
SdkTools=`cat /Users/christopher/Library/Developer/Xamarin/android-sdk-macosx/tools/source.properties | grep Pkg.Revision | tail -c 7`
echo $SdkTools
SdkPlatformTools=`cat ~/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/source.properties | grep Pkg.Revision | tail -c 7`
echo $SdkPlatformTools
SdkBuildTools=`ls ~/Library/Developer/Xamarin/android-sdk-macosx/build-tools | tail -n 1`
echo $SdkBuildTools
Java=`java -version 2>&1 | awk -F '"' '/version/ {print $2}'`
echo $Java
AppleDeveloperTools=`/usr/bin/xcodebuild -version | head -1 | sed -n -e 's/^.*Xcode //p'`
echo $AppleDeveloperTools
XMac=$(< /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version)
echo $XMac
XiOS=$(< /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/Version)
echo $XiOS
MacOSX=`sw_vers -productVersion`
echo $MacOSX
Visual Studio for Mac seems to use a own version of NuGet, because nuget help prints a different version than listed in Visual Studio's version information. In our build job we download the latest nuget.exe and use it to restore a solution. Therefore we retrieve the version of the nuget.exe:
NuGet=`echo $(mono nuget.exe help | head -1) | sed -n -e 's/^.*Version: //p'`

Related

flutter image_picker package compile error [ it works under 0.6.0 but not over ]

when I run flutter i got these messages.
Launching lib\main.dart on SM G930S in debug mode...
Running Gradle task 'assembleDebug'...
Plugin project :firebase_core_web not found. Please update settings.gradle.
Plugin project :location_web not found. Please update settings.gradle.
Plugin project :firebase_auth_web not found. Please update settings.gradle.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> File 'com.android.builder.files.ZipCentralDirectory#116a0403' was deleted, but previous version not found in cache
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 26s
Exception: Gradle task assembleDebug failed with exit code 1
my pubspect.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# a b c d e f g h i j k l m n o p q r s t u v w x y z
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
animated_floatactionbuttons: ^0.1.0
awesome_dialog: ^1.1.3
awsome_video_player: ^1.0.8+1
badges: ^1.1.1
cupertino_icons: ^0.1.3
carousel_slider: ^2.2.1
cached_network_image: ^2.2.0+1
cached_video_player: ^1.0.3
email_validator: ^1.0.5
firebase_auth: ^0.16.1
flutter_bloc: ^6.0.1
flutter_money_formatter: ^0.8.2
flutter_gifimage: ^1.0.0
flutter_speed_dial: ^1.2.5
flutter_styled_toast: ^1.3.0
flutter_swiper: ^1.1.6
flutter_svg: ^0.17.0
fluttertoast: ^7.0.2
flick_video_player: ^0.1.1
get: ^3.4.6
getwidget: ^1.1.3
geolocator: ^5.3.2+2
google_nav_bar: ^2.2.0
google_maps_flutter: ^0.5.30
http: ^0.12.2
image_stack: ^1.1.0
image_picker: ^0.5.4+3
path_provider: ^1.6.11
path: ^1.6.4
line_icons: ^0.2.0
location: ^3.0.0
logger: ^0.9.2
provider: ^4.3.2+1
url_launcher: ^5.5.0
shared_preferences: ^0.5.8
smooth_star_rating: ^1.1.1
regexpattern: ^0.2.3
video_player: ^0.10.12
video_player_controls: ^2.1.6
dev_dependencies:
flutter_test:
sdk: flutter
Flutter Doctor report
[√] Flutter (Channel unknown, v1.17.5, on Microsoft Windows [Version 10.0.18363.1016], locale ko-KR)
• Flutter version 1.17.5 at C:\src\flutter
• Framework revision 8af6b2f038 (8 weeks ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\Silenmus\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.47.3)
• VS Code at C:\Users\Silenmus\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.13.2
[√] Connected device (2 available)
• SM G930S • ce0416040ac8423d04 • android-arm64 • Android 8.0.0 (API 26)
• sdk gphone x86 • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
I tried these to solve this problem
made new project and all copy of my project packages and run it
=> it works == I think it's not packages dependency problem
run AVD same error occurs
Changed image_picker version
=> ^0.5.4+3 works
=> over ^0.6.0 doesn't
I have no idea what's wrong with me or code or package or flutter 😫
# animated_floatactionbuttons: ^0.1.0
# awsome_video_player: ^1.0.8+1
# cached_video_player: ^1.0.3
# flutter_bloc: ^6.0.1
# regexpattern: ^0.2.3
# flick_video_player: ^0.1.1
i remove unused packages and it works
if someone who like me ,
remove package one by one it could save your debugging time. 😉

Build error with map_view, flutter & gradle?

I get a build error using flutter version 1.2.2 and map_view version 0.0.14.
I tried to use this code in build.gradle
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
I followed all the steps here https://pub.dartlang.org/packages/map_view#-readme-tab-
I have an api-key but get the following build error
Finished with error: Please review your Gradle project setup in the
android/ folder.
* Error running Gradle: ProcessException: Process "C:\Users\Almoit PC\Desktop\MyApp\Map\flutter_app2\android\gradlew.bat" exited
abnormally:
Configure project :map_view
WARNING: The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.2.1.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '27.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
FAILURE: Build failed with an exception.
What went wrong: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.2.51 and higher. Project 'android' is using
version 1.1.2-4.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 10s Command: C:\Users\Almoit
PC\Desktop\MyApp\Map\flutter_app2\android\gradlew.bat app:properties
flutter doctor -v
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17763.437], locale en-AI)
• Flutter version 1.2.1 at C:\flutter
• Framework revision 8661d8aecd (10 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = C:\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 33.4.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[√] Connected device (1 available)
• SPH L520 • 2d81b4cf • android-arm • Android 4.4.2 (API 19)
• No issues found!

Error initializing task Copy: Not registered task Copy

I am just getting started working in Xamarin. I am trying to join a group project hosted on GitHub. I have cloned the project and updated the submodules. The problem I am having is that when I build the project I get this error:
Error initializing task Copy: Not registered task Copy.
The others guys in my group haven't ever seen this problem and don't know what could be causing it. I have searched online for solutions to the problem. Most posts suggest updating Xamarin and/or Xcode - I have done both and am still getting the same error. I am able to build the sample Xamarin projects and load them onto devices without problems. I am currently using a Community license while I determine if I am going to be a long term contributor to the project. The guys in my group have Enterprise licenses.
Below is my "about" information for Xamarin. I just updated to Mac Sierra OS yesterday. I was seeing this problem before and after updating.
Xamarin Studio Community Version 6.1.1 (build 15) Installation UUID:
94d3f999-f138-4164-8006-6daff97f9dcf Runtime: Mono 4.6.1
(mono-4.6.0-branch-c8sr0/abb06f1) (64-bit) GTK+ 2.24.23 (Raleigh
theme)
Package version: 406010003
NuGet Version: 3.4.3.0
Xamarin.Profiler Not Installed
Apple Developer Tools Xcode 8.0 (11246) Build 8A218a
Xamarin.Mac Version: 2.10.0.103 (Xamarin Studio Community)
Xamarin.Android Version: 7.0.1.2 (Xamarin Studio Community) Android
SDK:
/Users/ryan.tensmeyer/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.0.3 (API level 15)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
SDK Tools Version: 25.2.2 SDK Platform Tools Version: 24.0.3 SDK Build
Tools Version: 24.0.2
Java SDK: /usr java version "1.8.0_102" Java(TM) SE Runtime
Environment (build 1.8.0_102-b14) Java HotSpot(TM) 64-Bit Server VM
(build 25.102-b14, mixed mode)
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Xamarin Android Player Not Installed
Xamarin.iOS Version: 10.0.1.8 (Xamarin Studio Community) Hash: 3983064
Branch: cycle8-sr0-xi Build date: 2016-09-23 15:34:54-0400
Build Information Release ID: 601010015 Git revision:
fa52f02641726146e2589ed86ec4097fbe101888 Build date: 2016-09-22
08:03:02-04 Xamarin addins: 75d65712af93d54dc39ae4c42b21dfa574859fd6
Build lane: monodevelop-lion-cycle8-sr0
Operating System Mac OS X 10.12.0 Darwin j76502.iconfitness.com 16.0.0
Darwin Kernel Version 16.0.0
Mon Aug 29 17:56:20 PDT 2016
root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64
Can someone help me resolve this error?

Xamarin android cannot find symbol extends android.support.v7.widget.CardView

Not able compile xamarin.android project with xamarin.forms(2.3.1.114).
Getting error as follows :
FrameRenderer.java(35,35): Error: error: cannot find symbol extends
android.support.v7.widget.CardView symbol: class CardView location:
package android.support.v7.widget(test2) javac
FrameRenderer.java(7,7): Error: error: cannot find symbol if
(getClass () == FrameRenderer.class) symbol: method getClass()
location: class FrameRenderer (test2) javac
=== Xamarin.Android ===
Version: 6.1.2.21 (Xamarin Indie) Android SDK:
/Users/krishnankm/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
SDK Tools Version: 25.1.7 SDK Platform Tools Version: 24.0.1 SDK Build
Tools Version: 24.0.1
Java SDK: /usr java version "1.8.0_31" Java(TM) SE Runtime Environment
(build 1.8.0_31-b13) Java HotSpot(TM) 64-Bit Server VM (build
25.31-b07, mixed mode)
For me i just needed to do clean solution then build solution and just run it on the device / emulator
This might be due to corrupted zip files.
Delete the Xamarin zip files (just cardview or all) in the
{Windows root directory}\Users{username}\AppData\Local\Xamarin
On the next build everything will be re downloaded (build would take sometime).

Java.lang.NoClassDefFoundError Issue when using Android Support Design NavigationView

Getting the following issue when using NavigationView on a app:
java.lang.NoClassDefFoundError: android.support.design.internal.NavigationMenuPresenter
I got the same issue in this sample project:
https://github.com/xamarin/monodroid-samples/tree/master/android5.0/Cheesesquare
Test:
Android 5.1
Extra information:
=====================
Xamarin Studio
Version 5.10.1 (build 6)
Installation UUID: 4f372b0c-765f-463b-9408-1bd0211e4e94
Runtime:
Mono 4.2.1 (explicit/6dd2d0d)
GTK+ 2.24.23 (Raleigh theme)
Package version: 402010102
Xamarin.Profiler
Not Installed
Apple Developer Tools
Xcode 7.2 (9548)
Build 7C68
Xamarin.Mac
Not Installed
Xamarin.Android
Version: 6.0.0.34 (Business Edition)
Android SDK: /Users/rdelrosario/Library/Developer/Xamarin/android-sdk-mac_x86
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.2
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Xamarin Android Player
Version: 0.6.5
Location: /Applications/Xamarin Android Player.app
Xamarin.iOS
Version: 9.4.0.0 (Business Edition)
Hash: 7322991
Branch: master
Build date: 2015-12-08 16:20:29-0500
Build Information
Release ID: 510010006
Git revision: 0b60eecdb531933734519c13257d16a780274aab
Build date: 2015-12-04 20:28:20-05
Xamarin addins: 9876fd7c9837977178411ec7375b4352c0a0d6af
Build lane: monodevelop-lion-cycle6-baseline
Operating System
Mac OS X 10.10.5
Darwin Rendys-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0
Tue Sep 1 21:23:09 PDT 2015
root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64
Fixed this issue by:
Cleaned Solution
Deleted projects /bin and /obj folders
Deleted Android.Support.Design, Android.Support.v7.RecyclerView and zips folder in path ~/.local/share/Xamarin/
Rebuild project
That's it. This forced Xamarin Studio to download and unzip the Android support files again correctly. Will take some time since needs to download the packages, should fix the issue after that.

Resources