[英]Unable to install apk in android emulator. App contains ARM native code
[英]Run commands Android Terminal Emulator. Install apk by code
我正在尝试在Android Terminal Emulator上运行命令。 我的设备已经植根并且安装了superuser.apk 。
我是这样做的:
try {
Process process = Runtime.getRuntime().exec(cmd);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = bufferedReader.readLine();
while ( line != null ) {
Log.i("SHELL", line);
line = bufferedReader.readLine();
}
} catch ( Exception e) {
e.printStackTrace();
}
还有:
try {
Process process = Runtime.getRuntime().exec(<b>cmd</b>*);
process.waitFor();
} catch ( Exception e ){
e.printStackTrace();
}
我正在尝试安装。 通过代码进行APK。 我尝试了以下方法:
cmd => pm install /mnt/sdcard/app.apk
没有任何结果。
cmd => su -c "pm install /mnt/sdcard/app.apk"
用单引号,双引号和无引号引起来。 结果:
I/SHELL(1432): Usage: su [options] [LOGIN]
I/SHELL(1432): Options:
I/SHELL(1432): -c, --command COMMAND pass COMMAND to the invoked shell
I/SHELL(1432): -h, --help display this help message and exit
I/SHELL(1432): -, -l, --login make the shell a login shell
I/SHELL(1432): -s, --shell SHELL use SHELL instead of the default in passwd
I/SHELL(1432): -v, --version display version number and exit
I/SHELL(1432): -V display version code and exit. this is
I/SHELL(1432): used almost exclusively by Superuser.apk
其他命令,如ls运行正常。
如何安装/ mnt / sdcard中的apk?
谢谢!
尝试这个 :
su -c "pm install /mnt/sdcard/app.apk" root
但是我认为,如果您没有root权限,这是行不通的
我找到了解决方案。
Process p;
try {
// Preform su to get root privledges
p = Runtime.getRuntime().exec("su");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes(**any command**+"\n");
// Close the terminal
os.writeBytes("exit\n");
os.flush();
try {
p.waitFor();
if (p.exitValue() != 255) {
// Sucess :-)
}
else {
// Fail
}
} catch (InterruptedException e) {
// Fail
}
} catch (IOException e) {
// Fail
}
谢谢大家!
我怀疑在执行命令而不是ADB Shell时是应用程序的Shell环境。
来自代码:(如果您想通过Intent进行操作)
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path+"/<application_name>.apk")), "application/vnd.android.package-archive");
startActivity(intent);
这就是权限。
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.