7

I was modyfing my android app, and I was trying it on real device (Run Application in eclipse) and all was working good. So When I was satisfied of my changes, I opened the Manifest in order to modify the version for releasing it, but WITHOUT ANY CHANGES in Manifest an error occurred at line:

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

the error is:

Permission is only granted to system apps

How is this possible? I builded my application many times using this line.

GVillani82
  • 17,196
  • 30
  • 105
  • 172

3 Answers3

18

Thanks to all. I solved the strange problem with

 Project > Clean

Now all works good again!

GVillani82
  • 17,196
  • 30
  • 105
  • 172
  • 2
    Don't upvote this answer - it has nothing to do with the actual problem, which is that **this permission is NOT AVAILABLE to third party applications**. Nothing a developer can do on a secured device will change that fact. – Chris Stratton May 13 '13 at 20:16
  • This does answer the question of how to get it to compile again. AFAIK INSTALL_PACKAGES is a signatureOrSystem permission, so as long as your app is added to the system image that the device is ROMed with it should work, then subsequent versions signed with the same key should also get the permission when installed as updates. – Martin Belcher - AtWrk Jul 19 '13 at 11:43
2

you may not install packages yourself, don't even ask about that.

use Intent for that purpose:

Intent installIntent = new Intent(Intent.ACTION_VIEW );
installIntent.setDataAndType(
    Uri.parse("file://" + context.getFilesDir().getAbsolutePath() + "/" + file_name_to_install),
    "application/vnd.android.package-archive");
startActivity(installIntent);

if you were using Eclipse, most probably it has used old/outdated version of your Manifest, and when you open it, the changes were reloaded and brought up the error message. just remove offending permission and use Intents.

lenik
  • 23,228
  • 4
  • 34
  • 43
  • 1
    I need to install new apk from my app. I use this method for several months and I have not encountered any problems. But today manifest show my this error, without any change! – GVillani82 Nov 23 '12 at 14:56
  • The android.permission.INSTALL_PACKAGES indicates that your app is able to install other apps but since this permission can only be given to system apps, your app does not apply. Here is some more info: http://stackoverflow.com/questions/3476600/why-are-these-permissions-being-refused – Alex Fu Nov 23 '12 at 14:58
  • 2
    @Joseph82 you might have used earlier versions of SDK, but the current one considers `INSTALL_PACKAGE` permission as dangerous and added to the "System or Signed" class. That means user applications **cannot** use this permission, unless the application is installed in `/system/app` or signed with the manufacturer certificate – lenik Nov 23 '12 at 15:06
  • This permission was never available - if it was present in the Manifest of earlier versions it was simply being ignored. The key fact is that it never worked for 3rd party apps, and is not needed to start the install process with an Intent. – Chris Stratton May 13 '13 at 20:17
2

Cleaning will work if you have already changed in your lint preferences. Else check the below solution.

Permission is only granted to system app

It says to change your Lint Settings

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 -> Inspections

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

Community
  • 1
  • 1
Jimit Patel
  • 4,265
  • 2
  • 34
  • 58