如何使用系统权限编译Android应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3598662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:54:47  来源:igfitidea点击:

How to compile Android Application with system permissions

androidpermissions

提问by Michalis

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

我需要编译具有系统权限的应用程序才能使用目标应用程序 com.android.settings。现在,当我尝试运行我的 apk 时,我收到错误消息

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

测试运行失败:权限拒绝:从 pid=354, uid=354 开始检测 ComponentInfo{com.jayway.test/android.test.InstrumentationTestRunner} 不允许,因为包 com.jayway.test 没有与目标 com 匹配的签名。 android.settings

How can I compile my application with system permissions?

如何使用系统权限编译我的应用程序?

回答by Michalis

After having some search I found how to sign my application with system (platform) key. System signatures are located in directory <root-of-android-source-tree>/build/target/product/security. You can use them to sign your application with system privileges.

经过一番搜索后,我找到了如何使用系统(平台)密钥对我的应用程序进行签名。系统签名位于目录中<root-of-android-source-tree>/build/target/product/security。您可以使用它们以系统权限对您的应用程序进行签名。

回答by Marko Katic

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

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

  1. 添加到清单 android:sharedUserId="android.uid.system"

  2. 下载系统签名文件:platform.x509.pem platform.pk8

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

链接: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
  1. 通过终端签名应用程序(java -jar signapk.jar platform.x509.pem platform.pk8 unsigned.apk signed.apk)(首先你必须把所有文件放在一个文件夹中),或者用keytool-importkeypair制作证书来制作google_certificate.keystore进而

link for keytool-importkeypair download and explanation:

keytool-importkeypair 下载和说明链接:

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

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

  1. After that steps install your signed system app to your device. Good luck!!!
  1. 在这些步骤之后,将您签名的系统应用程序安装到您的设备上。祝你好运!!!

回答by Mike Mitterer

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.

对我来说,答案只是删除 debug.keystore 文件。AVD 的默认存储位置在 OS X 和 Linux 上的 ~/.android/,Windows XP 上的 C:\Documents and Settings\.android\ 和 Windows Vista 上的 C:\Users\.android\。

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

在 Eclipse 中,我“清理”了项目,从模拟器中卸载了 App 和 TestApp,然后 - 瞧,一切又恢复正常了。