Ajith Kamath
Ajith Kamath

Reputation: 51

APIs not getting hidden even after using the annotation @hide in Android

I am writing my own SDK on android and as such creating my own jar. Now I create documentation of my SDK using droiddoc tool.

In my framework files(.java), there are many APIs that I have marked with @hide Now this is the current state:

a) all APIs marked with @hide are hidden in documentation.

b) These APIs marked hidden is INCLUDED in class files in generated jar file.(I use Java decompiler to check this).

Now when I include this jar in eclipse and use Ctrl+space on my class object to find its options, i can see that hidden APIs are actually visible and accessible here.

Am I missing anything here, and do I need to add any special flags in make file? Or is this a normal behaviour?

Upvotes: 2

Views: 1708

Answers (1)

George D
George D

Reputation: 2365

I found out that:

android.jar has all classes from com.android.internal removed, and all classes, enums, fields and methods marked with @hide removed as well

So the classes with @hide are not included on jar -> that's why they are not accessible in eclipse. Furthermore:

When you launch your application on device it loads framework.jar (roughly this is equivalent of android.jar on the device) which is uncut and has all the internal API classes and all hidden API components.

Have a look over this post and this answer
Hope you find an alternative solution for hiding things

Upvotes: 2

Related Questions