Android - 如何在我的项目中添加@hide 注释

时间:2022-11-25
本文介绍了Android - 如何在我的项目中添加@hide 注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 SDK,我想将 @hide 注释用于我不希望使用我的 SDK 的用户看到的方法/类.(与 活动实施 - 第 3898 行)

I'm developing SDK, and I would like to use @hide annotation for methods/classes which I don't want to be visible for the user who uses my SDK. (same as in Activity implementation - line 3898)

我尝试添加 @hide 注释,但我发现没有任何反应.为了使用 @hide 注释/或任何其他类似的解决方案来封装我的内部 SDK 的类/方法,我需要做什么.

I tried just to add @hide annotation but I saw that nothing happens. What should I need to do in order to use @hide annotation/or any other similar solution for encapsulating my internal SDK's classes/methods.

推荐答案

在Android SDK中,@hide注解只在构建android.jar.在编译时从这个存根 jar 导入符号,并且只有非隐藏符号可用.在设备或模拟器中运行时,符号位于平台库中,例如可以通过反射看到它们.

In Android SDK, the @hide annotation is only used when building the stub version of android.jar. At compile-time symbols are imported from this stub jar and only non-hidden symbols are available. At runtime in device or emulator the symbols are there in the platform libraries and they can be seen for example via reflection.

如果你的 SDK 只包含一个 jar 文件或类似的东西,那么真的没有办法在其中隐藏符号.

If your SDK only consists of a jar file or something similar, there really isn't a way to hide symbols in it.

这篇关于Android - 如何在我的项目中添加@hide 注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!