Android manifest file breaks after adding a permis

2020-03-30 06:04发布

问题:

I have a really strange problem with an Android project I inherited. I tried adding a permission to it and suddenly a few other permissions break with the red "X" being displayed along with this error:

"Permission is only granted to system apps."

How could this be if all I did was add a permission? If I don't save the manifest and clean the project, all the red "X" marks go away and it compiles again. Why is this happening?

回答1:

In Eclipse, goto

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.



回答2:

There are some permissions (e.g., MODIFY_PHONE_STATE) which can be granted only to applications which have been signed with system's certificate. So if you trying to add one of those permission, then Lint will raise a red flag while compiling application's manifest file.