@UnsupportedAppUsage注解表示什么?

32
2个回答

29

如果我们前往注释源代码

/**
 * Indicates that a class member, that is not part of the SDK, is used by apps.
 * Since the member is not part of the SDK, such use is not supported.
 *
 * <p>This annotation acts as a heads up that changing a given method or field
 * may affect apps, potentially breaking them when the next Android version is
 * released. In some cases, for members that are heavily used, this annotation
 * may imply restrictions on changes to the member.
 *
 * <p>This annotation also results in access to the member being permitted by the
 * runtime, with a warning being generated in debug builds.
 *
 * <p>For more details, see go/UnsupportedAppUsage.
 *
 * {@hide}
 */

基本上,它意味着应用程序正在使用它,尽管它在技术上不是SDK的一部分,因此不受支持。这似乎更像是对为AOSP做贡献的人的警告,而不是你需要过多担心的事情。


5

以上注释来源的描述是正确的。我现在的代码中出现了一个异常,而之前却没有。我正在通过TextView.class中的一些字段设置光标处理程序的颜色,这些字段现在不被支持,并导致异常发生,在Pie上我不能设置句柄颜色,这不仅仅是一个警告。


3
这个标志只是一个警告。你因为Pie引入的隐藏API黑名单而遇到了错误,并在Q中进一步受到限制。我在这里写了几种绕过此限制的方法:https://dev59.com/RlMI5IYBdhLWcg3wi8Ab - TheWanderer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接