setContentView 使用的是非 SDK 接口 [英] setContentView is using non-SDK interface

查看:16
本文介绍了setContentView 使用的是非 SDK 接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在具有 API 28 的模拟器中运行我的应用程序时,控制台会给我以下警告:

When I run my application in an emulator with the API 28, the console gives me the following warning:

W/oaristachimene:访问隐藏方法Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z(浅灰名单,反射)W/oaristachimene:访问隐藏方法Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V(轻灰名单,反射)

W/oaristachimene: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection) W/oaristachimene: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)

我一直在调试它,我发现它来自调用:setContentView(R.layout.activity_main),那么还有另一种方法来设置活动的布局还是这个方法将被更新,以便在具有 android API 28 的设备上运行时不会引发该警告?

I have been debugging it and I found out that it comes from the call: setContentView(R.layout.activity_main), so is there another way to set the layout of an activity or is this method going to be updated so that it doesn't throws that warning when running on a device with android API 28?.

推荐答案

对于问题中的警告,computeFitSystemWindowsmakeOptionalFitsSystemWindows实际上是被支持库或者androidx使用的图书馆通过反思.您可以通过简单地在 AppCompatDelegateImpl 中搜索这两个方法来验证它.

For the warnings in the question, computeFitSystemWindows and makeOptionalFitsSystemWindows are actually used by the support library or androidx library through reflection. You can verify it by simply searching those two methods in the AppCompatDelegateImpl.

希望以后可以修复.

更新 1

最近我在 Firebase 测试实验室测试应用时,这 2 个 API 和其他一些 API 都被标记了

Recently when I test app in Firebase Test Lab, these 2 APIs and some other APIs are marked

此警告的一个可能根本原因是 Google 拥有的库 UI 工具包.目前无需采取任何措施.

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

或者

此警告的一个可能根本原因是 Google 拥有的库 Android WebView.目前无需采取任何措施.

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

这篇关于setContentView 使用的是非 SDK 接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆