xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Android] Review Android platform for Restrictions on non-SDK interfaces #4118

Open PureWeen opened 6 years ago

PureWeen commented 6 years ago

Description

https://developer.android.com/about/versions/pie/restrictions-non-sdk-interfaces https://android.googlesource.com/platform/frameworks/base/+/pie-release/config/hiddenapi-light-greylist.txt

This is a bit of an awkward situation with google because a lot of these cases are issues on the google side

https://stackoverflow.com/a/53736775 https://stackoverflow.com/a/59435170

Also, these APIs jump lists every so often for example

API Landroid/graphics/drawable/DrawableContainer;->getOpticalInsets()Landroid/graphics/Insets;

Was white listed in API 29

So for now we're just keeping track of these warnings here and fixing whatever we find

These are the ones that we are currently aware of.

If you run across more please let us know. In order to get an accurate list of grey listed APIs please make sure you are building with the latest version of android and running on a device with a matching API

If you're curious to see the stack traces causing these GreyLists to trigger you can add this to your MainActivity

protected override void OnCreate(Bundle bundle)
{
    if ((int)Build.VERSION.SdkInt >= 28)
    {
        StrictMode.SetVmPolicy(new StrictMode.VmPolicy.Builder()
                 .DetectNonSdkApiUsage()
                 //.PenaltyListener(Executors.NewSingleThreadExecutor(), this)
                 .PenaltyLog()
                 .Build());
    }

If you do this and find that one of our APIs are to blame then please let us know.

What if an API gets blacklisted ?

If an API that we aren't calling gets blacklisted then the only way to resolve the issue is to upgrade to a newer version of Forms that uses the latest Support/AndroidX/API

BioTurboNick commented 5 years ago

Just noting that I've seen these warnings in Google Play for:

android.support.v4.app.FragmentManagerImpl.getAnimationListener(FragmentManager.java:1301) android.support.v7.widget.ViewUtils.makeOptionalFitsSystemWindows(ViewUtils.java:80) android.support.v7.widget.ViewUtils.makeOptionalFitsSystemWindows(ViewUtils.java:84)

on XF 3.6.0.220655 and Support libraries 28.0.0.1

overzealus commented 4 years ago

I've got this warnings for XF 3.3.0.967583 and Xamarin.Android.Support.* 28.0.0.3: API Landroid/graphics/drawable/DrawableContainer;->getOpticalInsets()Landroid/graphics/Insets;

API Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z

API Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V

API Landroid/view/animation/Animation;->mListener:Landroid/view/animation/Animation$AnimationListener;

API Ljava/nio/Buffer;->address:J

API Landroid/content/Context;->bindServiceAsUser(Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/Handler;Landroid/os/UserHandle;)Z

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(III)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionAction(IIILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(II)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextClassification;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionModified(IILandroid/view/textclassifier/TextSelection;)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;->selectionStarted(I)Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->(Landroid/content/Context;I)V

API Landroid/view/textclassifier/logging/SmartSelectionEventTracker;->logEvent(Landroid/view/textclassifier/logging/SmartSelectionEventTracker$SelectionEvent;)V

irongut commented 4 years ago

For a simple Shell based app on Android 10 Q using Xamarin Forms 4.4.0.991265 with Xamarin.Android 28.0.0.3, Firebase reports use of 4 non-SDK interfaces which are incompatible with Android P+.

For the first 3 reports Firebase says:

One possible root cause for this warning is Google-owned library AndroidX. No action need be taken at this time.

But, this is not listed for the last reported interface. (and I'm not actually using AndroidX in this app)