Я пытаюсь выполнить двоичный файл aapt (на эмуляторе x86). найдено здесь https://github.com/thejunkjon/android-tools/blob/master/build/android-9.0.0_r33/aapt/x86/bin/aapt (Не уверен, имеет ли это значение.)
Однако, когда я пытаюсь выполнить его, я получаю сообщение об отказе в разрешении в logcat
Когда я запускаю это приложение выдает ошибку, что у меня нет разрешения
Runtime runtime = Runtime.getRuntime();
try {
changeFilePermission(getFilesDir() + "/aapt");
runtime.exec(getFilesDir() + "/aapt");
} catch (IOException e) {
e.printStackTrace();
}
stacktrace:
I/e.myapplication: type=1400 audit(0.0:672): avc: denied { setattr } for name="aapt" dev="sdb3" ino=652260 scontext=u:r:untrusted_app:s0:c84,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c83,c256,c512,c768 tclass=file permissive=1
java.io.IOException: Cannot run program "/data/user/0/com.example.myapplication/files/aapt": error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
at java.lang.Runtime.exec(Runtime.java:695)
at java.lang.Runtime.exec(Runtime.java:525)
at java.lang.Runtime.exec(Runtime.java:422)
at com.example.myapplication.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:4785)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4694)
at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:69)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ClientTransactionHandler.executeTransaction(ClientTransactionHandler.java:55)
W/System.err: at android.app.ActivityThread.handleRelaunchActivityLocally(ActivityThread.java:4744)
at android.app.ActivityThread.access$3200(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1819)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6680)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
at java.lang.ProcessImpl.start(ProcessImpl.java:132)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 24 more
метод changeFilePermission:
@SuppressLint({"SetWorldWritable", "SetWorldReadable"})
public static void changeFilePermission(final String path) {
final File file = new File(path);
file.setReadable(true, false);
file.setExecutable(true, false);
file.setWritable(true, false);
}