Permission is only granted to system app

121,997

Solution 1

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.

Solution 2

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"

Solution 3

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.

Solution 4

tools:ignore="ProtectedPermissions"

Try adding this attribute to that permission.

Solution 5

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"

Share:
121,997

Related videos on Youtube

Caner
Author by

Caner

"My country is the world...and my religion is to do good." - Thomas Paine

Updated on July 08, 2022

Comments

  • Caner
    Caner almost 2 years

    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.

    • Andro Selva
      Andro Selva over 11 years
    • Caner
      Caner over 11 years
      @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.
  • Aaron
    Aaron about 9 years
    Thanks! In Android Studio 1.2, I found this under File -> Settings -> Editor -> Inspections.
  • Yoraco Gonzales
    Yoraco Gonzales over 7 years
    This is the right anwser. Why disabling the whole inspection when it is only partially needed. Thank you Sir!
  • purplecabbage
    purplecabbage over 6 years
    You'll need to add the namespace ... xmlns:tools="schemas.android.com/tools"
  • Nithinjith
    Nithinjith about 6 years
    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.
  • Ezekiel Baniaga
    Ezekiel Baniaga about 6 years
    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.
  • Beyondo
    Beyondo almost 6 years
    It was under Android > Lint > Correctness for me.