26

I want to add this permission to my Android manifest:

<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />

But after I paste this permission in my manifest, it tests red underline and says:

permission is only granted to system apps

What can I do?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Reza_Rg
  • 3,345
  • 7
  • 32
  • 48
  • What API call are you using that requires this permission? – A--C Nov 28 '12 at 03:12
  • @A--C I'm trying this tutorial. http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html – Reza_Rg Nov 28 '12 at 03:18
  • I can see why this app needs the permission. Have a a look at the comments though, other people have had this issue, at least on gingerbread. – A--C Nov 28 '12 at 03:20
  • 14
    I had the same problem. I solved it just by doing Project->Clean. See: http://stackoverflow.com/a/13531632/165674 – Dheeraj Vepakomma Dec 01 '12 at 09:57
  • @DheerajV.S.Thanks for your mention, but I used another solution! I copied all manifest content in clipboard, then erased all manifest from eclipse and then paste it to manifest from workspace! and it worked! :) – Reza_Rg Dec 01 '12 at 13:51
  • 1
    try this accepted answer: http://stackoverflow.com/questions/13801984/permission-is-only-granted-to-system-app – Noman May 29 '13 at 13:36
  • @Noman Wow! Good solution! i'll keep it in my mind, for my next projects. thanks. – Reza_Rg May 29 '13 at 13:53

7 Answers7

65

MODIFY_PHONE_STATE permission is granted to system apps only.

For your information, there are 2 types of Android apps: system & user

User apps are just all your normal app installations through the Google Play Store, Amazon Appstore or sideloading. These go into the /data partition of your Android phone, which is the part of the internal memory made available for user data and apps.

System apps are basically the apps that come pre-installed with your ROM. In a standard Android user environment, the user doesn’t have write access to the /system partition and thus, installing or uninstalling system apps directly isn’t possible.

In order to install an app as a system app on your Android device, your device must either be rooted or have a custom recovery installed (or both).

That being said, that error is actually wrong because you have a valid code and compilation should work. It would be better if it gave a warning instead. In Eclipse you can easily fix it. Just go to:

Window -> Preferences -> Android -> Lint Error Checking.

Find ProtectedPermission from the list and set the severity to something other than error(info for example). This way your project will still compile.

Community
  • 1
  • 1
Caner
  • 57,267
  • 35
  • 174
  • 180
6

MODIFY_PHONE_STATE is a system-only permission. System Apps are either pre-installed into a system folder or compiled by a manufacturer using their security certificate.

Hence, if you are trying to do this you are trying to use API which are no longer supported. With Android versions 2.3+ you can monitor incoming calls, but blocking is not allowed (i think from the link you posted thats what you're trying to do).

Android issues if you need to follow: Issue 15022 and Issue 14789

gsb
  • 5,520
  • 8
  • 49
  • 76
  • Yes, I was trying to block incoming calls, and so this problem really sucks. – Reza_Rg Nov 28 '12 at 03:36
  • So, how the are some apps on Play store which can do call blocking? – Reza_Rg Nov 28 '12 at 03:37
  • I dont they block calls. they say they do, but all what they can do is notify the user (when a blocked number calls), but cannot completely block it. All of this of course in Android 2.3+ versions. – gsb Nov 28 '12 at 03:38
4

This error appears in SDK 19 onwards, when you change the manifest. Do Project Clean and Build. It should clear this error.

2

just clean your project it will be fine like this :

project > Clean...

ROR
  • 271
  • 3
  • 29
1

Because this is the system level permission device developer not grant this so application development tools also warn against this so you have to

Simply Clean project & Rebuild this is it

Ajay Pandya
  • 2,417
  • 4
  • 29
  • 65
1

There are four types of Permission

Regular
Dangerous
Signed
Signed or System

The first two can be used by Simple Apps Other two can only be used by the app which is build in framework

sziraqui
  • 5,763
  • 3
  • 28
  • 37
Xar-e-ahmer Khan
  • 1,314
  • 15
  • 23
0

Find ProtectedPermission from the list in

Window -> Preferences -> Android -> Lint Error Checking.

and set the severity to something other than error(info for example). This way your project will still compile.

Mifeet
  • 12,949
  • 5
  • 60
  • 108
Khan
  • 151
  • 1
  • 4