Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Intellisense and code highlighting for Xamarin.Forms using .NET Standard

$
0
0

I have ported my my Xamarin.Forms core project over to .NET Standard.

Ever since I have done this I have lost all intellisense and code navigation. All the code highlighting is all over the place with 10s/100s of method calls all highlighted like an error.
Even typing /// to add a comment above a method fails to do anything.

I have deleted the userprefs file and this has resolved the code highlighting, but all intellisense and code navigation is still missing

By adopting the latest core approach I have now got a disastrous coding experience. Or I am I expecting to much.


Updated Visual studio now android won't even compile... why? I have wasted days now on this.

$
0
0

All I want is someone to explain to me how to update without destroying my entire project. Or is the solution to never update?

I have wasted days trying to get this shit to work. I haven't even worked on any of my changes I want to make because my workflow has been updated visual studio... droid wont compile. iOS has zero issues android at this point I should just start working on the next version of my app in Android studio.

I just don't understand.

Setting Cookies in a WebView

$
0
0

I received a request this morning to share how I set cookies in a webview so here it is, hope it's helpful. It's worked for me so far but feel free to comment on it if it can be improved.
First, you have to create a custom render for your webview in iOS and Android, there are many examples of how to do that so I won't go into that here.
In my shared code I have a UserInfo object that contains a CookieContainer:

    public class UserInfo
    {
        public static CookieContainer CookieContainer = new CookieContainer();
    }

In my (native) login page I have an event called OnLoginClickAsync which validates the login information. I create a HTTPClientHandler:

                var handler =  new HttpClientHandler {CookieContainer = UserInfo.CookieContainer};
                var httpClient = new HttpClient(handler);

Then save the resulting CookieContainer if the validation is successful:

                UserInfo.CookieContainer = handler.CookieContainer;

On the Android side in the OnElementChanged event for my web view renderer I use:

            var cookieManager = CookieManager.Instance;
            cookieManager.SetAcceptCookie(true);
            cookieManager.RemoveAllCookie();
            var cookies = UserInfo.CookieContainer.GetCookies(new System.Uri(AppInfo.URL_BASE));
            for (var i = 0; i < cookies.Count; i++)
            {
                string cookieValue = cookies[i].Value;
                string cookieDomain = cookies[i].Domain;
                string cookieName = cookies[i].Name;
                cookieManager.SetCookie(cookieDomain, cookieName + "=" + cookieValue);
            }

On the iOS side in the OnElementChanged event for my web view renderer I use:

            // Set cookies here
            var cookieUrl = new Uri(AppInfo.URL_BASE);
            var cookieJar = NSHttpCookieStorage.SharedStorage;
            cookieJar.AcceptPolicy = NSHttpCookieAcceptPolicy.Always;
            foreach (var aCookie in cookieJar.Cookies)
            {
                cookieJar.DeleteCookie(aCookie);
            }

            var jCookies = UserInfo.CookieContainer.GetCookies(cookieUrl);
            IList<NSHttpCookie> eCookies =
                (from object jCookie in jCookies
                 where jCookie != null
                 select (Cookie) jCookie
                 into netCookie select new NSHttpCookie(netCookie)).ToList();
            cookieJar.SetCookies(eCookies.ToArray(), cookieUrl, cookieUrl);

Also, if you want to use the cookie container in a straight call - not in a webview - just set it in the handler:

            var handler = new HttpClientHandler { CookieContainer = cookieContainer };
            var httpClient = new HttpClient(handler);

Live Player & Tuples

$
0
0

Is there an additional setting/package to get Live Player working with tuples? App works fine in simluator/emulator/devices. The error message that I receive when I attempt to "Live Run Current View":

  1. Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNameAttribute' cannot be found. Are you missing a reference?

  2. Predefined type 'System.ValueTuple `2' is not defined or imported.

Testing a xamarin forms project running the android project as the startup in debug mode. Android build linker behavior setting set to "Don't Link".

Live player android - Access to path denied

$
0
0

Hi,

I'm trying out the Xamarin Live player on a Oneplus 5 android 7.1 but I get the following error:

Built with 2 messages (1,1): error: Internal Build Error: Access to the path '/data/user/0/com.xamarin.live/files/C/dev/MyCompany/Some-Git/Some/src/SomeDemo/SomeDemo/' is denied. C:\dev\MyCompany\Some-Git\Some\src\SomeDemo\SomeDemo.Android\MainActivity.cs(1,1): error: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)

Debugging with a USB cable does seem to work and pairing my devices with Visual Studio to.

So anyone some ideas?

Thanks!

XLabs HybridWebView with transparent background

$
0
0

Hi,

I tried to override the OnElementChanged method on a custom renderer that inherit from HybridWebViewRenderer, in order to make transparent the background of my XLabs HybridWebView. It doesn't work, because the parent's method has not been marked as virtual. How can I make my HybridWebView transparent? This is my code:

[assembly: ExportRenderer (typeof (CustomHybridWebView), typeof (CustomHybridWebViewRenderer))]
namespace MyApp.iOS
{
    public class CustomHybridWebViewRenderer : HybridWebViewRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            this.Opaque = false;
            this.BackgroundColor = UIColor.Clear;
        }
    }
}

Path Error - PCLStorage

$
0
0

Hello.
I use the library of PSLtorage in my project.

                 FileData filedata = await CrossFilePicker.Current.PickFile ();
                 string filePath = filedata.FilePath;

There is a problem with Android:
When you receive a file from internal memory, the full path to the file is written correctly.
However, when using a file with the SD CARD, the path is distorted.
For example, instead of:
storage/sd-037-12F/folder
we get:
document/sd-037-12F:folder

HELP! Production Issue

$
0
0

Hello,

We have a situation =)

We have some data stored in Xamarin Insights Logs that I would like to extract -- and manipulate, then store in our database (we lost some production data).

A couple of questions:

Does Xamarin Insights provide a REST based API for me to call to extract the data?

Can anyone point me to a tutorial to get started?

Thanks in advance,
-Kuthair


Can only install from Visual Studio deployment

$
0
0

I'm working with some Panasonic FZ-A2 ToughPad's and can only get an application to successfully install through a Visual Studio deployment.

When our usual deployment route involving manual apk installation failed for multiple different build configurations the customer sent one of the tablets in for further troubleshooting. The app immediately installed and ran, for each of the build configurations (armeabi-v7a, x86_64, native assembly bundling, etc...), when deployed from Visual Studio.

These builds again failed when attempted to be installed onto another one of these devices (same make, model, os version, ...).

The second device did not have the Mono Shared Runtime (Mono.Android.DebugRuntime-1/base.apk) installed, and so became the prime suspect. However, upon receiving the second tablet the shared runtime was manually installed, but it had no effect (install still failed) and so was removed. A fresh (release) build was then deployed from Visual Studio, which again installed the shared runtime, and the app successfully installed and ran without issue. The app and shared runtime were then removed, and just the (freshly built) app was manually reinstalled, which ran ok. That build was then removed and the previous build (that was successfully deployed to the first tablet) was then manually installed, though this time worked.

I'm not sure what the Visual Studio deployment operation is doing to the operating system's state to allow for the installation to work, but would like to know so I can include it into our manual deployment (installation) process to avoid requiring hardware be mailed out for installs and updates?

Missing Asset Catalog - Your app is missing the asset catalog file in

$
0
0

I am using visual studio 2017 on windows and updated all related tools. I am getting the above error using the Application Loader in Xcode. I have the Asset Catalogs folder in the root of my IOS project. It has Assets and Media objects. There is nothing showing in Assets. Media has AppIcons and LaunchImages. I filled in all the AppIcons. We use a story board for the launch screen with a logo so I don't have images which will the device, therefore, the LaunchImages object is empty. Does anyone have any insight into why I am my asset catalog is missing or steps I can do to ensure it is included? Also, are the launch images optional?

thanks

FFImageLoading - Image flickering on update source Forms android

$
0
0

Hi Guys,

Just a question before I start adding big code example, are you experimenting some flickering when Image source are updated in Android with FFImageLoading ?

The flickering does not happen when the image is render the first time. Here the image are load drom a website.

  <ffimageloading:CachedImage Grid.Row="0" Grid.Column="0" x:Name="AmbiancePicture"
                Aspect="Fill" FadeAnimationEnabled="true" FadeAnimationForCachedImages="true"
                DownsampleToViewSize="true" FadeAnimationDuration="100" FixedAndroidMotionEventHandler="true" > </ffimageloading:CachedImage>

If it's a bug I will open a bug in the GitHub.

The file "obj\Debug\android\bin\packaged_resources" does not exist.

$
0
0

I just bought an Indie license for Android and I receive the following error when I build a fresh new project in Xamarin Studio

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3,3): Error MSB6006: aapt.exe is afgesloten met code -1073741819. (MSB6006) (Dime.Scheduler)

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(3,3): Error MSB3375: The file "obj\Debug\android\bin\packaged_resources" does not exist. (MSB3375) (Dime.Scheduler)

More details about the build are in the attachment. Being a complete newbie to the mobile app development, I have no idea where to look and what to do next.

NSTableViewDataSource vs Key-Value Coding (MVVM), which is a better approach?

$
0
0

Quick intro... I'm writing an app for my company that supports iOS, Android, Windows, UWP, and finally getting around to the Mac platform.
App is nearly done for all other platforms except macOS. So far 80% code-reuse with iOS and Android, 60% Windows & UWP. Was hoping to leverage my ViewModel layer with macOS, but for obvious reasons, I cannot.

I came across this excellent xamarin resource for adding Data binding support to macOS apps. In that resource there is no mention of using a NSTableViewDataSource. By the way, all Xamarin Mac samples use a NSTableViewDataSource.

My question is, should I not even entertain the MVVM pattern for a macOS app, or should I utilize the NSTableViewDataSource approach? To me, it seems like the NSTableViewDataSource is akin to the classic WinForms code-behind methodology (for those of you who remember WinForms, pre-WPF days). In other words, limited extensibility and maintenance nightmares lie ahead.

I can't figure out how to databind my RelayCommand to the TableView's row double-click, but I can see how to do it using the NSTableViewDataSource, which at this point, leaning towards MVVM.

Any insight you have will be greatly appreciated.
thanks much,
Greg

(null) error passing values with Xamarin Player for iOS

$
0
0

We just tried to do the sample Xamarin forms app from this page.
developer.xamarin.com/guides/xamarin-forms/getting-started/hello-xamarin-forms/quickstart/

The only thing we did differently was we used a shared project vs a PCL.
Everything works great when we pull up the UWP app or Android app in Xamarin Live Player.
The issue is when we use try to use the Live player on iOS.
When we click the button to Translate we get an exception.
When we stepped through debugging when we call Core.PhonewordTranslator.ToNumber(phoneNumberText.Text) it passes in the value of (null).
That's not NULL, its a string with a values of "(null)" rather than the default "1-855-XAMARIN".

I don't have a Mac handy to test a real deployment to see if it is an issue there as well.

Has anyone else experienced this kind of issue?

I reported this on Bugzilla.
bugzilla.xamarin.com/show_bug.cgi?id=60789

view = new NSImageView(); causes application to crash

$
0
0

Hi there,

I’m converting a cocoa swift application to Xamarin.Mac. The original source had this snippet:

    if (view == nil)
    {
        view = [[[NSImageView alloc] init] autorelease];
    }
    _view = [view retain];

But, when I try to call
_view = new NSImageView();
The application crashes

I’m guessing the problem is somewhere in here...

    2   libsystem_c.dylib               0x00007fff985d8420 abort + 129
    3   MyApp               0x000000010c8b3b8b mono_handle_native_crash + 603 (mini-exceptions.c:2548)
    4   MyApp               0x000000010c831d06 altstack_handle_and_restore + 70 (exceptions-amd64.c:795)
    5   MyApp               0x000000010ca3fa70 sgen_client_par_object_get_size + 112 (sgen-client-mono.h:105)
    6   MyApp               0x000000010ca3f8f7 copy_object_no_checks + 71 (sgen-copy-object.h:70)
    7   MyApp               0x000000010ca3edcd simple_nursery_serial_scan_object + 1933 (sgen-minor-copy-object.h:228)

Is there a way to invoke the NSImageView parameterless constructor? And if not, is there a way I can instantiate this class without an image or a CGRect?


No exception details when debugging on android

$
0
0

When I debug my Xamarin.Forms app on UWP and an exception occurs, the application breaks on the line that the exception is thrown, showing me the exception details, the call stack, and allows me to inspect local variables. However, on android, every single time an exception occurs, I get this extremely unhelpful error:

The application is in Break Mode
Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).
An unhandled exception occurred

There are zero details about the exception. No stack trace. No local variables. Nothing.
(Note to the mods: it's really dumb that I'm not allowed to post a screenshot of this because I haven't been on the forums long enough)

Note, if I follow the exact same steps to reproduce any of these exceptions in UWP, the application breaks correctly on the exception and I am able to see the details. It is only in android that I get this useless page with no information.

I've tried adding unhandled exception handlers in my MainActivity, and added breakpoints, but when an exception occurs, the breakpoints never get hit and I still encounter the same useless error page:

[Activity(Label = "Redacted", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(bundle);

        global::Xamarin.Forms.Forms.Init(this, bundle);
        global::Xamarin.FormsMaps.Init(this, bundle);
        AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
        AndroidEnvironment.UnhandledExceptionRaiser += HandleAndroidUnhandledException;
        LoadApplication(new App());
    }

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
    {
        PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    private static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs args)
    {
        ErrorHandler.HandleException(args.ExceptionObject as Exception);
    }

    private static void HandleAndroidUnhandledException(object sender, RaiseThrowableEventArgs args)
    {
        ErrorHandler.HandleException(args.Exception);
    }
}

The following is in my Xamarin.Forms assembly:

public static class ErrorHandler
{
    public static void HandleException(Exception e)
    {
        #if DEBUG
            System.Diagnostics.Debugger.Break();
        #endif
        Application.Current.MainPage.DisplayAlert(e.GetType().Name, e.Message, "OK");
    }
}

I've also tried both with an emulated device and with a real device, and the same thing happens either way.

Why am I not seeing useful exception information when debugging on android? Is there something I can do in order to stop seeing this useless "The application is in Break Mode" message?

Cropping images to square in forms

$
0
0

I'm trying to get a user to select/take a picture and then getting a crop view up. I have managed to do this using this library: https://github.com/XAM-Consulting/Xam.Plugins.ImageCropper

But I want to force the image to be a square, not any aspect ratio the user pleases. Is there anyone who knows how to do this?

Is there any other library/plugin that I can use for this?

All my apps stop working after iOS upgrade. 2nd time

$
0
0

After upgrading the iOS version on my iPhone 5s all my test apps stopped working. This was the second time this happened. After 10.3 -> 11.0 and now after 11.0 ->11.1. Can I avoid having this happen in the future? After upgrading Visual Studio for PC, XCode, Xamarin Studio for MAC and deploying the app to the iPhone again everything works fine.

Layout with Xamarin.Forms

$
0
0

Hello! I need help!

How can I use different image from background for landscape and portrait?

I saw many things about to create folder drawable-land and drawable-port and to put the different image with the same name in both folders. But only this not worked.

I need to know how to create the layout with two background images since begin.

Thank you!

Silvia

Xamarin/Visual Studio/IOS and Firebase Database

$
0
0

The tutorials say "Add GoogleService-Info.plist file to your app project. 2. Set GoogleService-Info.plist build action behaviour to Bundle Resource by Right clicking/Build Action. 3. Add the following line of code somewhere in your app, typically in your AppDelegate's FinishedLaunching method (don't forget to import Firebase.Core namespace): "

This is Visual Studio and there is no "import" . There is a "using" and I have added using firebase.database. I have failed at the google-foo and cannot find a tutorial for visual studio/mac/xamarin and firebase database. Any direction to said tutorial or example would be greatly appreciated.

Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>