setContentView使用非SDK界面 [英] setContentView is using non-SDK interface
问题描述
当我使用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(light 灰名单,反思)
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?.
推荐答案
对于问题中的警告,支持库或androidx库通过反射实际上使用了computeFitSystemWindows
和makeOptionalFitsSystemWindows
.您可以通过简单地在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
.
是的,他们违反了他们设定的一些规则.希望以后可以解决.
Yes, they break some rules which are set by them. Hopefully this can fixed later.
更新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屋!