Android 将我的 apk 推送到 /system/app
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2007024/
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
Push my apk to /system/app
提问by Tsimmi
How can I push my application package to Android emulator "/system/app" folder?
如何将我的应用程序包推送到 Android 模拟器“/system/app”文件夹?
I've already tried to use:
"adb push myApk.apk /system/app"
and it gives me this:
我已经尝试使用:
“adb push myApk.apk /system/app”
,它给了我这个:
"failed to copy: ... No space left on device"
Although from settings -> sdCard & Phone Storage, I get 37Mb of internal free space.
虽然从设置 -> sdCard 和手机存储,我得到了 37Mb 的内部可用空间。
The whole point of this need is
related to permissions.
这种需求的全部意义
与权限有关。
I need to have INSTALL_PACKAGES permission
and I know that by puting my application there,
in /system/app, I get that permission.
我需要有 INSTALL_PACKAGES 权限
,我知道通过将我的应用程序
放在 /system/app 中,我获得了该权限。
采纳答案by Ryan Alford
Normally, the only way to get access to the "/system/" directory is to have a device rooted. I don't exactly know if that is required for the emulator though. That could be your issue.
通常,访问“/system/”目录的唯一方法是让设备植根。我不完全知道模拟器是否需要这样做。那可能是你的问题。
回答by posaidong
I can install an APK to /system/appwith following steps.
我可以/system/app通过以下步骤安装 APK 。
Push APK to SD card.
$ adb push SecureSetting.apk /sdcard/Enter the console and get the shell
$ adb shellSwitch to superuser. If your device is not rooted, get it rooted first. (If you don't know how to do that, just Google.)
$ suRemount the system partition with WRITE permission.
$ mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /systemCat your APK from
/sdcard/to/system/, some guys get a fail withcpcommand due tocpis not supported. So usecatinstead.$ cat /sdcard/SecureSetting.apk > /system/app/SecureSetting.apkRemout
/systempartition back to READ-ONLY, and exit$ mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system $ exit
将 APK 推送到 SD 卡。
$ adb push SecureSetting.apk /sdcard/进入控制台,获取shell
$ adb shell切换到超级用户。如果您的设备未植根,请先植根。(如果你不知道怎么做,就谷歌一下。)
$ su重新挂载具有 WRITE 权限的系统分区。
$ mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /systemCat your APK from
/sdcard/to/system/,有些人cp因为cp不支持命令而失败。所以cat改用。$ cat /sdcard/SecureSetting.apk > /system/app/SecureSetting.apk将
/system分区重新设置为 READ-ONLY,然后退出$ mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system $ exit
Then reboot your device, the APK should have been installed on /system/app.
然后重启你的设备,APK 应该已经安装在/system/app.
回答by kakopappa
These are the steps if you are installing a system apk for Android 5.0 or later devices. For older versions use posaidong's answer
如果您要为 Android 5.0 或更高版本的设备安装系统 apk,则这些是步骤。对于旧版本使用 posaidong 的答案
Rename your apk file to base.apk
将您的 apk 文件重命名为 base.apk
$ adb push base.apk /sdcard/
Enter the console and get the shell
进入控制台,获取shell
$ adb shell
Switch to superuser. If your device is not rooted, get it rooted first. (If you don't know how to do that, just Google.)
切换到超级用户。如果您的设备未植根,请先植根。(如果你不知道怎么做,就谷歌一下。)
$ su
Remount the system partition with WRITE permission.
重新挂载具有 WRITE 权限的系统分区。
$ mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Create a Test directory inside /system/app folder. (or can use /system/priv-app as well). Ideally this folder name should be application name. For now, lets use Test
在 /system/app 文件夹中创建一个测试目录。(或者也可以使用 /system/priv-app )。理想情况下,此文件夹名称应为应用程序名称。现在,让我们使用测试
$ mkdir /system/app/Test
Requires 755 permission for this dir
此目录需要 755 权限
$ chmod 755 /system/app/Test
Copy your base.apk inside
把你的 base.apk 复制进去
$ cat /sdcard/base.apk > /system/app/Test/Base.apk
Remout /system partition back to READ-ONLY, and exit
将 /system 分区重新设置为 READ-ONLY,然后退出
$chmod 644 /system/app/Test/Base.apk
Requires 644 permission for this dir
此目录需要 644 权限
$ mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
$ exit
Reboot your device. When boot completes you should see a system message like Android updating ...
重新启动您的设备。启动完成后,您应该会看到一条系统消息,例如 Android 更新...
回答by Pavel P
settings -> sdCard & phone storage says about /data folder.
设置 -> sdCard 和手机存储说明 /data 文件夹。
/system is mounted separately and I guess there is no way of writing there unless you make your own Android build.
/system 是单独安装的,我想除非您制作自己的 Android 版本,否则无法在那里编写。
See mounts by running
通过运行查看坐骑
adb shell
# df
回答by James Bullock
You need to run adb remountfirst, then it should let you adb pushto /systemfolders
你需要先运行adb remount,然后它应该让你adb push到/system文件夹
回答by Doug
The following batch file will install any apk files in the folder to the /system/app directory. It mounts the system drive as rw, then copies the files over.
以下批处理文件会将文件夹中的所有 apk 文件安装到 /system/app 目录。它将系统驱动器挂载为 rw,然后复制文件。
To use it, put the following code into a text editor and save it as install.bat on a Windows machine. Then double-click on the batch file to install any APK files that are in the same folder as the batch file.
要使用它,请将以下代码放入文本编辑器并在 Windows 机器上将其保存为 install.bat。然后双击批处理文件以安装与批处理文件位于同一文件夹中的任何 APK 文件。
NOTE: You can't remount the system partition unless you have root on the device. I've mostly used this on the emulator which defaults to root (And was the original question), but the concept should be the same on a physical device.
注意:除非您在设备上有 root,否则您无法重新挂载系统分区。我主要在默认为 root 的模拟器上使用它(这是最初的问题),但概念在物理设备上应该是相同的。
@ECHO OFF
%~d0
CD %~dp0
adb root
adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
adb shell rm /system/app/SdkSetup.apk
for /f %%a IN ('dir /b *.apk') do adb push %%a /system/app/.
回答by Mayuran Balasubramaniam
Use below commands from your super user ADB shell. Copy the APK of your APP into your SD card or Internal Storage.
在您的超级用户 ADB shell 中使用以下命令。将您的 APP 的 APK 复制到您的 SD 卡或内部存储中。
$ adb shell
$ su
$ mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
$ cp /sdcard/<Your_APK_PATH> /system/app/file_name_comes_here.apk
$ chmod 644 /system/app/<YourAPK>.apk
Then reboot the device
然后重启设备
回答by knmanish
Even before adb remountyou should change the permissions for the /system in the adb shell.
you can use chmodto change the permissions.
甚至在adb remount您应该更改 adb shell 中 /system 的权限之前。您可以使用chmod更改权限。
回答by neel
I have come across this situation multiple times while copying apk files to /systempartition and could finally resolve it using the following steps:
我在将 apk 文件复制到/system分区时多次遇到这种情况,最终可以使用以下步骤解决它:
Check the Freespace in
/systempartition using dffrom adb shell. Most probably the Free space would be less than size of apk file.Filesystem Size Used Free Blksize /dev 1.3G 80.0K 1.3G 4.0K /sys/fs/cgroup 1.3G 12.0K 1.3G 4.0K /mnt/secure 1.3G 0.0K 1.3G 4.0K /mnt/asec 1.3G 0.0K 1.3G 4.0K /mnt/obb 1.3G 0.0K 1.3G 4.0K /system 3.5G 3.5G 10.0M 4.0K /efs 15.7M 2.8M 12.9M 4.0K /cache 192.8M 736.0K 192.1M 4.0K /data 25.5G 12.7G 12.8G 4.0K /persdata/absolute 4.9M 120.0K 4.8M 4.0K /sbfs 10.8M 8.0K 10.7M 4.0K /mnt/shell/knox-emulated 25.5G 12.7G 12.8G 4.0K /mnt/shell/privatemode 25.4G 12.7G 12.7G 4.0K /mnt/shell/emulated 25.4G 12.7G 12.7G 4.0K /preload 5.8M 3.3M 2.5M 4.0KUse du /systemto get sizes of each folder & file in
/systempartition. Arrange the output in descending order of size(s) to get (something similar):4091840 /system/ 1199416 /system/app 964064 /system/priv-app 558616 /system/lib64 373320 /system/lib 206624 /system/vendor 170952 /system/app/WebViewGoogle 148824 /system/app/WebViewGoogle/lib 125488 /system/voice 125480 /system/voice/embedded 122880 /system/app/Chrome 106520 /system/framework 102224 /system/priv-app/Velvet 96552 /system/app/SBrowser_3.0.38 93936 /system/vendor/lib64 93792 /system/vendor/lib64/egl 92552 /system/tts 92512 /system/tts/lang_SMT ...Delete unnecessary files from
/system/voice/embedded,/system/tts/lang_SMT(for language/locale support) and/or other folders to free enough space in/systempartition to accommodate the new apk file. Deleting files in partitions other than/systemmay not help in this scenario. (N.B.: This step may require ROOT privileges and remounting/systempartition in read-write mode using mount -o rw,remount /system)
检查自由空间
/system使用分区DF从亚行外壳。最有可能的可用空间将小于 apk 文件的大小。Filesystem Size Used Free Blksize /dev 1.3G 80.0K 1.3G 4.0K /sys/fs/cgroup 1.3G 12.0K 1.3G 4.0K /mnt/secure 1.3G 0.0K 1.3G 4.0K /mnt/asec 1.3G 0.0K 1.3G 4.0K /mnt/obb 1.3G 0.0K 1.3G 4.0K /system 3.5G 3.5G 10.0M 4.0K /efs 15.7M 2.8M 12.9M 4.0K /cache 192.8M 736.0K 192.1M 4.0K /data 25.5G 12.7G 12.8G 4.0K /persdata/absolute 4.9M 120.0K 4.8M 4.0K /sbfs 10.8M 8.0K 10.7M 4.0K /mnt/shell/knox-emulated 25.5G 12.7G 12.8G 4.0K /mnt/shell/privatemode 25.4G 12.7G 12.7G 4.0K /mnt/shell/emulated 25.4G 12.7G 12.7G 4.0K /preload 5.8M 3.3M 2.5M 4.0K使用du /system获取
/system分区中每个文件夹和文件的大小。按大小的降序排列输出以获得(类似的东西):4091840 /system/ 1199416 /system/app 964064 /system/priv-app 558616 /system/lib64 373320 /system/lib 206624 /system/vendor 170952 /system/app/WebViewGoogle 148824 /system/app/WebViewGoogle/lib 125488 /system/voice 125480 /system/voice/embedded 122880 /system/app/Chrome 106520 /system/framework 102224 /system/priv-app/Velvet 96552 /system/app/SBrowser_3.0.38 93936 /system/vendor/lib64 93792 /system/vendor/lib64/egl 92552 /system/tts 92512 /system/tts/lang_SMT ...从
/system/voice/embedded,/system/tts/lang_SMT(用于语言/区域设置支持)和/或其他文件夹中删除不必要的文件,以释放/system分区中足够的空间以容纳新的 apk 文件。/system在这种情况下,删除分区以外的文件可能无济于事。(注意:此步骤可能需要 ROOT 权限并/system使用mount -o rw,remount /system以读写模式重新挂载分区)
回答by Marc Climent
You have to mount system as read/write and then push the application.
您必须将系统挂载为读/写,然后推送应用程序。
This is answered in this question: Push .apk to /system/app/ in HTC HERO
这在这个问题中得到了回答:在 HTC HERO 中将 .apk 推送到 /system/app/

