0

In android studio how I can import libraries not in public SDK such as android.os.ServiceManager ? there exist any command that I can write in gradle files to fix this problem?

ofskyMohsen
  • 1,121
  • 1
  • 12
  • 26

1 Answers1

1

The ServiceManager which is part of android.jar is marked with the @hide annotation.

In design time, all classes, enums, fields and methods marked with hide annotation are exclude in the android.jar, although in runtime android load framework.jar (equivalent to android.jar) which contains also the classes, methods, enums and fields marked with the hide annotation.

Although, you can access in design time using reflection or building the android.jar with theses classes inside it.

Take into consideration you cannot publish your app on Google Play because you are in breach of EULA.

erv-Z
  • 87
  • 1
  • 5
  • I saw UnifiedNLP(an unbundled location provider) code in github , they imported LocationProviderBase that is @hide too . How they do this ? – ofskyMohsen Jun 14 '17 at 16:35
  • How I can build android.jar with classes inside it ? – ofskyMohsen Jun 14 '17 at 16:50
  • [Building android.jar](http://www.politisktinkorrektpappa.com/2016/04/22/android-hidden-and-internal-apis-revisited/). They can import *LocationProviderBase* because they are in android.jar's scope, where they are building the android.jar – erv-Z Jun 14 '17 at 18:41