Running the current Preview channel of Visual Studio Mac, v8.3 build 1630, my Xamarin.Android app reports a Newtonsoft.Json.JsonReaderException.
The code below works fine in the current Stable channel of Visual Studio for Mac, v8.2.6 (build 28).
Do I need to update something for VS for Mac v8.3?
Code
readonly static HttpClient _client = new HttpClient();
public static async Task<MyModel> GetModelFromApi()
{
using (var response = await _client.GetAsync("https://my.api.url/endpoint").ConfigureAwait(false))
{
var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return JsonConvert.DeserializeObject<MyModel>(json);
}
}
Stack Trace
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: �. Path '', line 0, position 0.Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: �. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonReader.ReadAndMoveToContent () [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonReader.ReadForType (Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) [0x0004a] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at JsonParseTextRepro.ApiService.GetPun () [0x0013f] in <a23104cc471e42a78acea59e0c31e721>:0
at JsonParseTextRepro.App+DemoPage.OnAppearing () [0x00091] in <a23104cc471e42a78acea59e0c31e721>:0
Environment Info
=== Visual Studio Enterprise 2019 for Mac (Preview) ===
Version 8.3 Preview (8.3 build 1630)
Installation UUID: 6e5142b4-e8be-4d1c-b75e-4744b0d8c3de
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)
=== Xamarin.Android ===
Version: 10.0.0.40 (Visual Studio Enterprise)
Commit: xamarin-android/d16-3/080eaac
Android SDK: /Users/brandonm/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
None installed
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.2
SDK Build Tools Version: 28.0.3
Build Information:
Mono: mono/mono#6434153
Java.Interop: xamarin/java.interop#5836f58
LibZipSharp: grendello/LibZipSharp/d16-3#71f4a94
LibZip: nih-at/libzip#b95cf3f
ProGuard: xamarin/proguard#905836d
SQLite: xamarin/sqlite#8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools#cb41333
Answer
This is a regression in the Managed Linker where it is incorrectly removing the Xamarin.Android.Net.AndroidClientHandler library.
The Xamarin team is aware of the issue and you can track the status of it here:
https://github.com/xamarin/xamarin-android/issues/3626
Work Around
To prevent the linker from removing the AndroidClientHandler library, you can add it to the Ignore assembles option in the Android Build settings.
Related
I'm experiencing some odd behavior where a Provider behaves differently in debug vs. release mode.
This question is posted in off this question.
Here is a short description of the functionality: I have a list of ExpansionTiles (containing TextFormFields in their body) and a FloatingActionButton that adds to the list of ExpansionTiles. Below those two widgets I have one Back button and one Next button. The Next button needs be "unavailable" (ie. throw an error message to the user and have the color grey) as long as any TextFormField in the list of ExpansionTiles is incomplete. Once all TextFormFields are ready the Next button should change color and direct the user to a new page. Changing the color and functionality works fine in debug, but not in release mode (ie. after running: flutter build web).
Firstly: TravelProceedModel monitors the status of whether the user can click the Next button or not. Ie. this is just a simple bool. Whenever updateCanProceed() is called I update canProceed and also notifyListeners().
import 'package:flutter/material.dart';
class TravelProceedModel extends ChangeNotifier {
bool canProceed;
void updateCanProceed(bool value) {
canProceed = value;
notifyListeners();
}
}
Secondly, the TravelProceedModel is implemented using the ChangeNotifierProvider and then using Consumer. I'm expecting (and this works in debug) that when canProceed is changed this line: "nextEnabled: proceedModel.canProceed" should cause the button the change color. However, this only works in debug mode.
class TravelDeductionTrips extends StatefulWidget {
#override
_TravelDeductionTripsState createState() => _TravelDeductionTripsState();
}
class _TravelDeductionTripsState extends State<TravelDeductionTrips> {
#override
Widget build(BuildContext context) {
String year = Provider.of<UserSelectionsModel>.(context).selected_report["year"];
String report = Provider.of<UserSelectionsModel>(context).selected_report["report"];
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => TravelProceedModel()
),
ChangeNotifierProvider(
create: (context) => TravelModel(
year: year,
report: report,
),
),
],
child: Consumer<TravelModel>(
builder: (context, travelModel, child) {
return FutureBuilder(
future: travelModel.fetchTripsToLocalSession(),
builder: (context, data) {
if (data.connectionState == ConnectionState.done) {
return Column(
children: <Widget>[
TravelDeductionTripList(),
Consumer<TravelProceedModel>(
builder: (context, proceedModel, child) {
proceedModel.updateCanProceed(
travelModel.checkProceedCondition()
);
return BackNextButtons(
backEnabled: true,
nextEnabled: proceedModel.canProceed,
backText: "Tilbage",
nextText: travelModel.trips["next_action_title"],
errorMessage: travelModel.proceedErrorMessage,
nextFunction: () async {
await addQuestionIDtoStack(year, report, travelModel.trips["next_question_id"], true);
}, // No special function is needed, this is just a simple next
);
},
),
],
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}
);
}
),
);
}
}
NB! proceedModel.canProceed is updated from within TravelDeductionTripList() which calls
Provider.of<TravelProceedModel>(context, listen: false).updateCanProceed(
Provider.of<TravelModel>(context, listen: false).checkProceedCondition()
);
The Next button only changes colors after reloading the widget. Ie. it appears that the TravelProceedModel is being updated but that the widget is not being redrawn in the UI - although it happens perfectly in debug mode.
Does anybody have any idea why debug works but release does not?
Below is my "flutter doctor -v". Notice, that this is a flutter web project.
[✓] Flutter (Channel beta, v1.15.17, on Mac OS X 10.15.2 19C57, locale en-US)
• Flutter version 1.15.17 at /Users/danni/Documents/flutter/flutter
• Framework revision 2294d75bfa (13 days ago), 2020-03-07 00:28:38 +0900
• Engine revision 5aff311948
• Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/danni/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✗] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
✗ CocoaPods installed but not working.
You appear to have CocoaPods installed but it is not working.
This can happen if the version of Ruby that CocoaPods was installed with is different from the one being used
to invoke it.
This can usually be fixed by re-installing CocoaPods. For more info, see
https://github.com/flutter/flutter/issues/14293.
To re-install CocoaPods, run:
sudo gem install cocoapods
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 41.0.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.43.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1
[✓] Connected device (2 available)
• Chrome • chrome • web-javascript • Google Chrome 80.0.3987.149
• Web Server • web-server • web-javascript • Flutter Tools
! Doctor found issues in 1 category.
I had the same problem, and I've made a workaround for it.
Since listen is a parameter, you can pass any other bool variable to it (should not be a constant true or false).
There is a built-in bool variable in foundation.dart package called kReleaseMode.
So here is an example, how i handled this listener problem between debug and release mode:
await Provider.of<AuthService>(context, listen: kReleaseMode).loginUser(
user: _username, password: _password);
For me, it works perfectly.
I am getting an error when trying to build a simple F# project on macOS High Sierra.
$ mono --version
Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Sun Sep 17 18:29:46 BST 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen (concurrent by default)
Steps:
Open VS Code
Ionide New F# Project
Choose the Suave Project Template
$ mono .paket/paket.exe install
$ ./build.sh
The error is:
1) System.Exception: dotnet build failed
at FSI_0005.Build+runDotnet#40.Invoke (System.String message) [0x00001] in <c9993ec69ddb4848af99438005012ea7>:0
at Microsoft.FSharp.Core.PrintfImpl+StringPrintfEnv`1[TResult].Finalize () [0x00012] in <5893d081904cf4daa745038381d09358>:0
at Microsoft.FSharp.Core.PrintfImpl+Final1#224[TState,TResidue,TResult,A].Invoke (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] env, A a) [0x00038] in <5893d081904cf4daa745038381d09358>:0
at Microsoft.FSharp.Core.OptimizedClosures+Invoke#3253[T2,TResult,T1].Invoke (T2 u) [0x00001] in <5893d081904cf4daa745038381d09358>:0
at FSI_0005.Build.runDotnet (System.String workingDir, System.String args) [0x00048] in <c9993ec69ddb4848af99438005012ea7>:0
at FSI_0005.Build+clo#64-6.Invoke (System.String p) [0x0000a] in <c9993ec69ddb4848af99438005012ea7>:0
at Microsoft.FSharp.Collections.SeqModule.Iterate[T] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] action, System.Collections.Generic.IEnumerable`1[T] source) [0x0002d] in <5893d081904cf4daa745038381d09358>:0
at FSI_0005.Build+clo#62-5.Invoke (Microsoft.FSharp.Core.Unit _arg4) [0x0000b] in <c9993ec69ddb4848af99438005012ea7>:0
at Fake.TargetHelper+targetFromTemplate#209-1[a].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00001] in <59b649fdccf1c534a7450383fd49b659>:0
at Fake.TargetHelper.runSingleTarget (Fake.TargetHelper+TargetTemplate`1[a] target) [0x0004b] in <59b649fdccf1c534a7450383fd49b659>:0
How can I get this working?
Ionide did not pick the correct target framework by default.
You need to make the following changes:
To *.fsproj, change the target framework to:
<TargetFramework>netcoreapp2.0</TargetFramework>
To paket.dependencies, change the framework to:
framework: >= netcoreapp2.0
Run Paket again:
$ mono .paket/paket.exe install
Run the build script again:
$ ./build.sh
I created ServiceStack F# projects using Visual Studio 2013 and ServiceStackVS. I then created a "ServiceStack Self Hosted Empty" project using F#. It works.
However, I'm unable to get the project working after 'containerizing' it with Docker and attempting to run it under boot2docker. I have a tried-and-tested boot2docker in VirtualBox configuration running on the Windows machine. SSH'ing into boot2docker and using shared folders to access the Windows file system from within boot2docker. The Dockerfile builds successfully:
Dockerfile:
FROM mono:3.10
RUN apt-get -qq update && apt-get -qqy install unzip socat
ADD . /var/www/
WORKDIR /var/www/
RUN nuget install SelfHost03/SelfHost03/packages.config -o packages
RUN xbuild SelfHost03.sln
EXPOSE 8080
CMD /usr/bin/socat -s EXEC:"mono SelfHost03/SelfHost03/bin/Debug/SelfHost03.exe",ignoreeof -,ignoreeof
also tried:
ENTRYPOINT ["mono","SelfHost03/SelfHost03/bin/Debug/SelfHost03.exe"]
But, when I try to run the container, I receive the following:
ServiceStack SelfHost listening at http://localhost:8080
Unhandled Exception:
System.ComponentModel.Win32Exception: Cannot find the specified file
at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x0
0000] in :0
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x
00000] in :0
at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in :0
at System.Diagnostics.Process.Start (System.String fileName) [0x00000] in :0
at SelfHost03.Main.main (System.String[] argv) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ComponentModel.Win32Exception: Cannot find the specified file
at System.Diagnostics.Process.Start_shell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x0
0000] in :0
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x
00000] in :0
at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in :0
at System.Diagnostics.Process.Start (System.String fileName) [0x00000] in :0
at SelfHost03.Main.main (System.String[] argv) [0x00000] in :0
It took some time which was a result of my lack of familiarity with F# but, the problem arises with the addition/inclusion of:
Process.Start("http://localhost:8080/") |> ignore
Recreating the C# project using the update templates includes the equivalent:
Process.Start("http://localhost:8080/");
After removing these statements, the projects will continue to run on Windows and the derived Docker images/containers will work too.
I am developing an iOS application using Xamarin.iOS and Visual Studio.
When I debug on the iPhone Simulator, it works great. But if I try to build the app with iPhone configuration, it doesn't work.
When I build the app, the debug output display this :
(_BuildNativeApplication cible) ->
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(148,3): error : Remote build step failed. [C:...csproj]
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(148,3): error : [C:...csproj]
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.MonoTouch.Common.targets(148,3): error : Remote build step failed. [C:....csproj]
0 Warning(s)
2 Error(s)
Temps ‚coul‚ 00:01:56.41
However, the Mac Server Log output indicates that the build is not stopped. But it shows this error for all my views:
[2013-07-10 18:32:58.2] Warning: Fail moving file /Users/me/Library/Caches/Xamarin/mtbs/builds/myProj/7855596c-fbd7-487f-a36f-3b8d9c6493c0/output/Release/iPhone/myProj.app/View.nib to bundle dir: /Users/me/Library/Caches/Xamarin/mtbs/builds/myProj/7855596c-fbd7-487f-a36f-3b8d9c6493c0/bundle/myProj.app/View.nib
[2013-07-10 18:32:58.2] Warning: Exception type: System.IO.FileNotFoundException
[2013-07-10 18:32:58.2] /Users/me/Library/Caches/Xamarin/mtbs/builds/myProj/7855596c-fbd7-487f-a36f-3b8d9c6493c0/output/Release/iPhone/myProj.app/View.nib does not exist
[2013-07-10 18:32:58.2] at System.IO.File.Move (System.String sourceFileName, System.String destFileName) [0x00000] in <filename unknown>:0
[2013-07-10 18:32:58.2] at MonoTouch.Tools.Tools.IBTool.MoveIBFileToBundleDirectory (System.String path) [0x00000] in <filename unknown>:0
and it ends with
[2013-07-10 18:33:14.8] Command [Build: CommmandUrl=Build] finished (110)
So my idea was to take the created app file (from [2013-07-10 18:33:14.8] Command [Build: CommmandUrl=Build] finished (110) ) and add it manually on the device (with iTunes).
The install works but when I launch the app, I just can see the UI elements I created in the C# code, all the elements created in the .xib are unreachable and invisible.
After that, I tried to follow this guide for ad-hoc deployment : http://docs.xamarin.com/guides/ios/deployment,_testing,_and_metrics/app_distribution_overview/ipa_support_for_ad_hoc_and_enterprise_deployment but the install never starts using iTunes.
Does someone have a solution to deploy a Xamarin.iOS app from Visual Studio? (I clarify I have 8 xib files in my project and all of theme are defined as InterfaceDefinition (for the generation)).
I had this problem too after making updates.
The solution was to change the two systems for the stable version.
It was in alpha.
Do not forget to close and reopen VS. In my case did update the sdk.
Here is a bit of code that won't win awards for complexity:
[<EntryPoint>]
let main argv =
let i = 1I
printfn "One is %A\n" i
0 // return an integer exit code
It's compiled as follows: "c:/Program Files (x86)/Microsoft SDKs/F#/3.0/Framework/v4.0/Fsc.exe" --out:numericstest.exe --debug:full --target:exe --standalone Program.fs
Under Windows it produces the expected result. However under Mono 3.0.7 compiled under Ubuntu it instead says:
mono numericstest.exe
Unhandled Exception: System.InvalidProgramException: Invalid IL code in System.Numerics.BigInteger:get_One (): method body is empty.
at Program.main (System.String[] argv) [0x00000] in <filename unknown>:0[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in System.Numerics.BigInteger:get_One (): method body is empty.
at Program.main (System.String[] argv) [0x00000] in <filename unknown>:0
What am I doing wrong please? Many thanks.
There's nothing wrong with your code -- that exception is due to your code anyway. It looks like there's something wrong with the System.Numerics.dll assembly on your machine; either it's not installed correctly, it's getting compiled incorrectly (e.g., by the Mono C# compiler), or it's doing some kind of type forwarding which is not working like it should, etc.
What happens if you run the code without using BigInteger (via the I suffix)?
I tried your code in my Ubuntu (12.04, 32-bit) VM running under VirtualBox. The code compiled and ran as expected. Here's the output if you want:
Compile/Run
jack#jack-linux:~/Desktop$ fsharpc --out:JoeHuha.exe --debug:full --target:exe --standalone JoeHuha.fs
F# Compiler for F# 3.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
jack#jack-linux:~/Desktop$ mono JoeHuha.exe
One is 1
Mono version info
jack#jack-linux:~/Desktop$ mono -V
Mono JIT compiler version 3.0.5 (master/1643364 Fri Feb 22 19:31:07 EST 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)