問(wèn)題描述
我正在開(kāi)發(fā) SDK,我想將 @hide 注釋用于我不希望使用我的 SDK 的用戶(hù)看到的方法/類(lèi).(與 活動(dòng)實(shí)施 - 第 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 注釋?zhuān)野l(fā)現(xiàn)沒(méi)有任何反應(yīng).為了使用 @hide 注釋/或任何其他類(lèi)似的解決方案來(lái)封裝我的內(nèi)部 SDK 的類(lèi)/方法,我需要做什么.
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
注解只在構(gòu)建android.jar
.在編譯時(shí)從這個(gè)存根 jar 導(dǎo)入符號(hào),并且只有非隱藏符號(hào)可用.在設(shè)備或模擬器中運(yùn)行時(shí),符號(hào)位于平臺(tái)庫(kù)中,例如可以通過(guò)反射看到它們.
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 只包含一個(gè) jar 文件或類(lèi)似的東西,那么真的沒(méi)有辦法在其中隱藏符號(hào).
If your SDK only consists of a jar file or something similar, there really isn't a way to hide symbols in it.
這篇關(guān)于Android - 如何在我的項(xiàng)目中添加@hide 注釋的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!