Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I sign my application with the system signature key?

Tags:

android

I need to create a Robotium application that would use Settings application to turn ON/OFF WIFi from menu Settings->Wireless & networks->Wi-Fi. I managed to find some sample code here that demonstrates how to launch application by having apk file only. The problem is that my Robotium application should have the same signature with the (system) Settings application. While trying to run application 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

  1. Can I somehow make it work with the Android Emulator?
  2. If I compile an Android phone image, how can I use the Android system signature with my application?
like image 391
Michalis Avatar asked Aug 24 '10 13:08

Michalis


People also ask

How do I sign an app with platform key?

You need to get 2 files in "/build/target/product/security" in AOSP sources. You can sign your app with these files or you can generate "jsk" file and use it in Android Studio when you sign it.

How do you sign an app as a system app?

To build your app as a system app instead of a user app, add the attribute android:sharedUserId="android. uid. system" into the <manifest> tag in the AndroidManifest. xml file of your Android app.

How do I get the APK sign key?

To sign your app using Android Studio, and export an existing app signing key, follow these steps: If you don't currently have the Generate Signed Bundle or APK dialog open, click Build > Generate Signed Bundle/APK. In the Generate Signed Bundle or APK dialog, select either Android App Bundle or APK and click Next.


1 Answers

I was having the same problem.. There are some permissions that only system apps are allowed to have . I was trying to access the adb shell dumpsys commands from my application with the permissions android.permission.DUMP .

The solution to this is ...

In the Android manifest file of your project add the following line in the manifest tag

android:sharedUserId="android.uid.system"

You need to have two signature keys present in the code that is used to build the binary.

platform.x509.pem

platform.pk8

that is present in the

android/build/target/product/security

Download a tool from the net i.e.

signapk.jar

From the eclipse export your unsigned apk. by right click on the project from the android tools. Keep all the things i.e. keys , unsigned apk, and signapk.jar in a folder. Run the following Command

java -jar signapk.jar platform.x509.pem platform.pk8 unsigned.apk signed.apk

unsigned apk is the name of your apk and signed apk is the new name you want . After this just install your signed app in the phone with the command

adb shell install signed.apk
like image 171
Nirmit Srivastava Avatar answered Nov 03 '22 15:11

Nirmit Srivastava