Bug 60427 - Android 8.0 AutoTextSize being ignored
Summary: Android 8.0 AutoTextSize being ignored
Status: RESOLVED ANSWERED
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: Production (addons.xamarin.com)
Hardware: PC Mac OS
: Highest blocker
Target Milestone: ---
Assignee: Jon Dick
URL:
Depends on:
Blocks:
 
Reported: 2017-10-29 21:04 UTC by Tom Opgenorth
Modified: 2017-11-14 21:36 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
VS4M project (53.69 KB, application/zip)
2017-10-29 21:04 UTC, Tom Opgenorth
Details
Android Studio application for comparison (165.34 KB, application/zip)
2017-10-29 21:08 UTC, Tom Opgenorth
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Tom Opgenorth 2017-10-29 21:04:48 UTC
Created attachment 25495 [details]
VS4M project

I tried to create a quick sample showing the AutoSize text properties available in Android 8.0 Oreo. The same app works when deployed to a device running Android 8.0, but nothing happens when running on a device < API 26. This happens even when trying programatically.

Steps to Duplicate:
1. Unzipped attached Visual Studio for Mac solution. 
2. Run solution on a device that is running a version of Android < 8.0.




Information about Visual Studio for Mac on my computer: 
=== Visual Studio Enterprise 2017 for Mac ===

Version 7.2 (build 636)
Installation UUID: ef2cd217-c6d2-4b3a-8525-cd01cc0c9e21
Runtime:
	Mono 5.4.0.201 (2017-06/71277e78f6e) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 504000201

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.0.0
	1.1.2
	1.0.5
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Versions:
	2.0.0
	1.0.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

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

=== Xamarin.Android ===

Version: 8.0.0.33 (Visual Studio Enterprise)
Android SDK: /Users/tom/Library/Android/sdk
	Supported Android versions:
		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)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.1
SDK Build Tools Version: 26.0.2

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

=== Apple Developer Tools ===

Xcode 9.0.1 (13249)
Build 9A1004

=== Xamarin.iOS ===

Version: 11.2.0.11 (Visual Studio Enterprise)
Hash: 2f8bbec0
Branch: d15-4-xi
Build date: 2017-10-05 20:56:05-0400

=== Xamarin Inspector ===

Version: 1.3.2
Hash: 461f09a
Branch: 1.3-release
Build date: Tue, 03 Oct 2017 18:26:57 GMT
Client compatibility: 1

=== Xamarin.Mac ===

Version: 3.8.0.49 (Visual Studio Enterprise)

=== Build Information ===

Release ID: 702000636
Git revision: b349c8fc0c2e1aab0179917d56eed75eb3a03337
Build date: 2017-10-06 15:20:04-04
Xamarin addins: a8da992c78f7eb65b3cdb3f951c34a30337cab35
Build lane: monodevelop-lion-d15-4

=== Operating System ===

Mac OS X 10.13.0
Darwin 17.0.0 Darwin Kernel Version 17.0.0
    Thu Aug 24 21:48:19 PDT 2017
    root:xnu-4570.1.46~2/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Internet of Things (IoT) development (Preview) 7.1
Comment 1 Tom Opgenorth 2017-10-29 21:08:51 UTC
Created attachment 25496 [details]
Android Studio application for comparison

This project, in Android Studio and translated to Kotlin, demonstrates that the AutoText size works on devices running older (i.e. < Android 8.0) versions of Android.
Comment 2 Jon Douglas [MSFT] 2017-10-30 01:35:42 UTC
(In reply to Tom Opgenorth from comment #1)
> Created attachment 25496 [details]
> Android Studio application for comparison
> 
> This project, in Android Studio and translated to Kotlin, demonstrates that
> the AutoText size works on devices running older (i.e. < Android 8.0)
> versions of Android.

I think I know why this isn't working.

Inside the support-compat library there are many TextViewCompat classes:

TextViewCompat.class
TextViewCompatApi23.class
TextViewCompatGingerbread.class
TextViewCompatJb.class
TextViewCompatJbMr1.class
TextViewCompatJbMr2.class

However the support-compat(https://www.nuget.org/packages/Xamarin.Android.Support.Compat/) binding only has:

TextViewCompat

Thus when it tries to construct the proper implementation < API 26:

    int version = Build.VERSION.SDK_INT;
    if (version >= 23) {
      IMPL = new Api23TextViewCompatImpl();
    } else if (version >= 18) {
      IMPL = new JbMr2TextViewCompatImpl();
    } else if (version >= 17) {
      IMPL = new JbMr1TextViewCompatImpl();
    } else if (version >= 16) {
      IMPL = new JbTextViewCompatImpl();
    } else {
      IMPL = new BaseTextViewCompatImpl();
    }

It fails to find these classes. Thus this explains why it only "partially" works on Oreo devices and fails on older than Oreo devices. Even on Oreo it is not working correctly as the app:autoSizeTextType will not work unless these classes are present. Thus I am CONFIRMING this issue and changing the priority to HIGHEST BLOCKER due to the severity of a missing binding.
Comment 3 Jon Douglas [MSFT] 2017-10-30 01:36:21 UTC
Changing product to components based on the nature of the fix.
Comment 4 Jon Dick 2017-11-14 21:36:23 UTC
One minor detail which I've missed so many times in the past when I run into these really seemingly weird issues:

AppCompatActivity!

Basically anything in life must subclass AppCompatActivity and not the normal Activity .... It's almost so bad we should have a linter warning if a user subclasses Activity.

Anyway, your sample needs to subclass AppCompatActivity, and then all should work as expected.