How to compile Android Application with system permissions

Viewed 51096

I need to compile an application with system permissions in order to use target application com.android.settings. For now while I try to run my apk I get the error message

Test run failed: Permission Denial: starting instrumentation ComponentInfo{com.jayway.test/android.test.InstrumentationTestRunner} from pid=354, uid=354 not allowed because package com.jayway.test does not have a signature matching the target com.android.settings

How can I compile my application with system permissions?

3 Answers
  1. Add to manifest android:sharedUserId="android.uid.system"

  2. Download System signatures files: platform.x509.pem platform.pk8

link: https://android.googlesource.com/platform/build/+/android-8.0.0_r17/target/product/security/

  1. Sign app through terminal (java -jar signapk.jar platform.x509.pem platform.pk8 unsigned.apk signed.apk) (first you must put all files to one folder), or make certificate with keytool-importkeypair to make google_certificate.keystore and then

link for keytool-importkeypair download and explanation:

https://github.com/getfatday/keytool-importkeypair

  1. After that steps install your signed system app to your device. Good luck!!!

The anser for me was simply delete the debug.keystore file. The default storage location for AVDs is in ~/.android/ on OS X and Linux, in C:\Documents and Settings\.android\ on Windows XP, and in C:\Users\.android\ on Windows Vista.

In Eclipse I "cleaned" the project, uninstalled the App and the TestApp from the emulator and - voila everything ran fine again.

Related