3

I am getting following error while building android source, where i have added my custom app which uses android.os.ServiceManager.

cannot find symbol
symbol  : class ServiceManager
location: package android.os
import android.os.ServiceManager;

Why am I facing this error, actually this import can be found in many other app in android source.

I am building the android source as in http://source.android.com/source/building.html and also followed this post The import android.os.ServiceManager cannot be resolved answers.

and for more info, I am building in [android root]/packages/app/ directory

Please can anybody help me to solve this ?

Adam Lear
  • 38,111
  • 12
  • 81
  • 101
Charan Pai
  • 2,288
  • 5
  • 32
  • 44

1 Answers1

7

solved :) Have to remove LOCAL_SDK_VERSION := current from Android.mk file

Charan Pai
  • 2,288
  • 5
  • 32
  • 44
  • 1
    Why that so ? any idea – Aada Jul 13 '17 at 12:33
  • It's because of ServiceManager is System Api/ hidden api means only system apps can use this API. By removing LOCAL_SDK_VERSION := current, we are changing app's SDK version. This is always not a solution ultimately in near future you must have to find an alternative way of this class. [Google is already restricting hidden apis. https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces ] – Bajrang Hudda Oct 19 '21 at 11:25