115

I have a System app that uses system permissions and I have those permissions listed in the manifest. Eclipse gives the following error when I try to make a build(command line build works):

Permission is only granted to system apps

I'm already aware that my app requires system permissions and it is not a problem for me because my application will be used only on rooted phones. So I want to suppress this error, anyone knows how?

EDIT
My project already compiles fine on command line, installs, runs etc.. My problem is about eclipse giving an error for a legit manifest file.

Caner
  • 57,267
  • 35
  • 174
  • 180
  • 2
    Did u check this http://stackoverflow.com/q/9494965/603744 – Andro Selva Dec 10 '12 at 13:34
  • @AndroSelva it is unrelated, my project already compiles fine on command line, installs, runs etc.. My problem is about eclipse giving an error for a legit manifest file. IMO it should only produce a warning in this case. – Caner Dec 10 '12 at 13:36

7 Answers7

218

In Eclipse:

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

In the list find an entry with ID = ProtectedPermission. Set the Severity to something lower than Error. This way you can still compile the project using Eclipse.

In Android Studio:

File -> Settings -> Editor -> Inspections

Under Android Lint, locate Using system app permission. Either uncheck the checkbox or choose a Severity lower than Error.

Ameer
  • 2,709
  • 1
  • 28
  • 44
Ole
  • 7,899
  • 2
  • 29
  • 34
  • 1
    Thanks! In Android Studio 1.2, I found this under File -> Settings -> _Editor_ -> Inspections. – Aaron May 13 '15 at 18:20
  • I want to change the screen brightness programmatically. I have edited the Lint under settings. But it's throwing some security exception while trying to change the screen brightness programmatically. Anyone have any solution to implement this feature in Android 3.1 above Marshmallow, please share. – Nithinjith Apr 09 '18 at 03:18
  • 4
    In Android Studio 2.1, Go to File -> Settings -> Editor -> Inspections then expand Android > Lint > Correctness. Select "Using system app permission", change severity or uncheck the checkbox. – Ezekiel Baniaga Apr 09 '18 at 03:48
  • 3
    It was under `Android > Lint > Correctness` for me. – Beyondo Sep 05 '18 at 04:34
106

To ignore this error for one instance only, add the tools:ignore="ProtectedPermissions" attribute to your permission declaration. Here is an example:

<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
    tools:ignore="ProtectedPermissions" />

You have to add tools namespace in the manifest root element

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
crgarridos
  • 8,758
  • 3
  • 49
  • 61
Jesta
  • 1,387
  • 2
  • 9
  • 9
13

Have same error from time to time (when I set install location to "prefer external" in manifest). Just clean and rebuild project. Works for me.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Amalia
  • 131
  • 1
  • 4
7
tools:ignore="ProtectedPermissions"

Try adding this attribute to that permission.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
user10206860
  • 71
  • 1
  • 1
4

when your add permission in manifest then in eclipse go to project and clic

  1. click on project
  2. click on clean project that's all

k on clean project

Adiii
  • 54,482
  • 7
  • 145
  • 148
3

Path In Android Studio in mac:

Android Studio -> Preferences -> Editor -> Inspections

Expand Android -> Expand Lint -> Expand Correctness

Uncheck the checkbox for Using system app permission

Click on "APPLY" -> "OK"

1

Preferences --> EditorEditor --> Inspections --> Android Lint --> uncheck item Using System app permissio

Văn Vũ
  • 11
  • 2