[英]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.