0

I want to download and install / remove APKs in background programmatically on a google glass device.

Steps i already tried:

  • Move APK to /system/priv-apps
  • Try to sign the APK with the system signature (I don't know if I signed it with the correct one)
  • Set the android sharedUserId to "android.uid.system" -> this gave me a permission error while installing

Can anybody help me getting my App signed by a system signature? I really do not want to code a shell script running on each boot..

I am also getting the following error while trying to exec the

pm install -r APK_PATH

command programmatically:

Error running exec(). Command: [su] Working Directory: null Environment: null

Please help me! :-)

MZs
  • 1
  • 1

1 Answers1

0

According to this documentation, be noted that the APK needs to meet the following criteria:

  • It must be zip-aligned.
  • You must not make any changes to the package name or private signing key after this (the Android package manager does not allow upgrades if either of these changes).
  • It must be smaller than 50 megabytes.
  • It must be compiled using the latest version of the GDK.

To sign the APK based from this thread,

On top of signing Android 1.6 for Dream with certificates generated by myself, I've also managed to sign my app with the platform certificate and run it with the system sharedUserId. These are the steps I took:

  • Build and flash to your Dream your own Android using http://source.android.com/documentation/building-for-dream. Use the mkkey.sh script on http://pdk.android.com/online-pdk/guide/release_keys.html to create new certificates, including x509 certificates before you do 'make'.
  • In the AndroidManifest.xml of your application: under the <manifest> element, add the attribute android:sharedUserId="android.uid.system".
  • Export an unsigned version of your Android application using Eclipse: right-click on the project >> Android Tools >> Export Unsigned Application Package.
  • Use <root-of-android-source-tree>/out/host/<your-host>/framework/signapk.jar to sign your app using platform.x509.pem and platform.pk8 in <root-of-android-source-tree>/build/target/product/security generated earlier:

    java -jar signapk.jar platform.x509.pem platform.pk8 YourApp-unsigned.apk YourApp-signed.apk.
    
  • Install the app to your device:

    adb install YourApp-signed.apk
    
  • Run your app
  • Use adb shell ps to confirm that your app is running as system.

Check these related forums:

Hope this helps!

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59