Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Previewer] SetDefaultActionBarTitleTextColor prevents the Android previewer from working #1407

Closed
garuma opened this issue Dec 15, 2017 · 15 comments · Fixed by #1561
Closed

Comments

@garuma
Copy link
Contributor

garuma commented Dec 15, 2017

Description

The SetDefaultActionBarTitleTextColor method (or any method for that matter) should not make assumption about a context being an Activity (that is never do ((Activity)_context)).

It should use the as operator and null-check the result instead (or ?. operator).

Steps to Reproduce

  1. Open a ContentPage xaml file with master Forms Previewer.
  2. Exception happens.

Expected Behavior

Works

Actual Behavior

Exception:

ERROR: : AndroidXamlRenderer had a rendering error: System.InvalidCastException: Specified cast is not valid.
at Xamarin.Forms.Platform.Android.Platform.SetDefaultActionBarTitleTextColor () in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\Platform.cs:924
at Xamarin.Forms.Platform.Android.Platform..ctor (Android.Content.Context context, System.Boolean embedded) in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\Platform.cs:64
at Xamarin.Forms.Platform.Android.Platform..ctor (Android.Content.Context context) in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1087

Basic Information

Screenshots

N/A

Reproduction Link

N/A

@pauldipietro pauldipietro added this to New in Triage Dec 15, 2017
@rmarinho rmarinho moved this from New to Ready For Work in Triage Dec 19, 2017
@alanmcgovern
Copy link
Contributor

/cc @jassmith :)

@alanmcgovern
Copy link
Contributor

Hey - this is a critical issue and we should be rolling out a fix at the earliest convenience. These unsafe casts are breaking the forms previewer in ways we cannot work around.

@alanmcgovern
Copy link
Contributor

Just for bookkeeping, a quick git grep "(Activity)" has 27 hits which means we have at least 27 places to review/change. There could be more though.

@StephaneDelcroix
Copy link
Member

while we're at it, SetDefaultActionBarTitleColor() isn't setting anything and should be renamed

@alanmcgovern
Copy link
Contributor

@jassmith @davidortinau What's the ETA on fixing this? Ideally we'd have this fixed, tested and hotfixed before the end of the week as it is triggering a critical breakage in the previewer

@davidortinau
Copy link
Contributor

Fix is underway. As soon as we know an ETA I'll share with you @alanmcgovern.

@hartez hartez removed this from Ready in v3.0.0 Jan 12, 2018
@hartez hartez added this to Ready in v3.1.0 via automation Jan 12, 2018
v3.1.0 automation moved this from Ready to Done Jan 15, 2018
@samhouts samhouts added this to Done in v3.0.0 Feb 13, 2018
@samhouts samhouts removed this from Done in v3.0.0 May 7, 2018
@samhouts samhouts removed this from Done in v3.1.0 May 7, 2018
@jlahare
Copy link

jlahare commented Jun 26, 2018

is this issue fixed ?

@ctrexler
Copy link

ctrexler commented Jul 9, 2018

I've updated Xamarin and everything and tried countless folk remedies I've encountered on the net and I'm still encountering this exact issue.

@hartez
Copy link
Contributor

hartez commented Jul 9, 2018

@ctrexler Which version of Visual Studio are you running? Which version of Xamarin.Forms are you currently using?

@jlahare
Copy link

jlahare commented Jul 10, 2018

@hartez : in my case, i am using Visual Studio 2017 community edition, Xamarin.Form 3.1.0.583944.

i tried by downgrading its different versions, no help.

@hartez
Copy link
Contributor

hartez commented Jul 10, 2018

@jlahare And you're getting the exact error message posted above? An InvalidCastException when calling SetDefaultActionBarTitleTextColor ()?

Are you on Mac or Windows?

@jlahare
Copy link

jlahare commented Jul 11, 2018

i am using Xamarin.Form in Microsoft Visual Studio Community edition over Windows 10 O.S.

@ctrexler
Copy link

@hartez I'm also using Visual Studio 17 commutiy with the latest Xamarin 3.1 and yes I'm receiving the exact error message of an invalid cast for SetDefaultActionBarTitleTextColor (). Also, I'm on Windows 10, and it's a preview build to be honest.

I might've figured something out though. I found out that my project is a Portable Class Library which went obsolete about a year ago. I'm going to copy everything over to a new Standard Class Library today. Could that by chance cause the issue? I'll let you know what happens after I make the transition if I don't hear from you sooner.

Thanks for the quick response and sorry for my slow one. I just now saw the notification.

@scotch83
Copy link

I still have this issue happening:

=== Visual Studio Community 2017 for Mac ===

Version 7.5.3 (build 7)
Installation UUID: f7b64361-98d4-4657-8a94-567d94b6c785
Runtime:
Mono 5.10.1.57 (2017-12/ea8a24b1bbf) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

Package version: 510010057

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: Not installed
SDK: Not installed
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.Mac ===

Version: 4.4.1.193 (Visual Studio Community)

=== Xamarin.Android ===

Version: 8.3.3.2 (Visual Studio Community)
Android SDK: /Users/Mattia/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.4 (API level 19)
5.1 (API level 22)
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.0
SDK Build Tools Version: 27.0.3

Java SDK: /usr
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Xamarin.iOS ===

Version: 11.12.0.4 (Visual Studio Community)
Hash: 64fece5f
Branch: d15-7
Build date: 2018-05-29 20:00:44-0400

=== Build Information ===

Release ID: 705030007
Git revision: 13cecd02aceddf29a1ed57b86f81c02994df1483
Build date: 2018-06-14 15:48:08-04
Xamarin addins: 7065de97cf22c9038fdc39dd627f2c30790fd8af
Build lane: monodevelop-lion-d15-7

=== Operating System ===

Mac OS X 10.11.6
Darwin 15.6.0 Darwin Kernel Version 15.6.0
Tue Jan 9 20:12:05 PST 2018
root:xnu-3248.73.5~1/RELEASE_X86_64 x86_64

@ctrexler
Copy link

ctrexler commented Jul 19, 2018

To update my last post, after moving everything over to a new Standard Class Library, the Xamarin.Forms previewer started working immediately. I don't know if having a PCL was the route cause, I'm just following up with my experience regarding this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants