如何将可执行文件放在Android 29上运行? [英] What path to put executable to run on Android 29?

查看:59
本文介绍了如何将可执行文件放在Android 29上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android应用程序包含一组可执行文件,这些可执行文件在首次运行时被提取到应用程序目录(/data/data/%package%/).如果定位到Android 28( targetSdkVersion ),它就可以正常工作.自2020年11月2日起,Google Play和所有定位到29.因此它停止与权限例外.

My Android app includes a set of executables that are extracted to app directory (/data/data/%package%/) on the first run. It worked just fine if targeted to Android 28 (targetSdkVersion). Since November 2, 2020 it not allowed in Google Play and all the apps must target to 29. So it stopped working with permission exception.

可执行文件应放置到哪个目录?

What directory should executables be put to now?

PS.一些类似的应用具有同一问题.

PS. Some similar apps have the same issue.

推荐答案

https://developer.android.com/about/versions/10/behavior-changes-10#execute-permission

定位到API 29(Android 10/Q)或更高版本时,就不再具有对存储在应用主目录(数据)中的文件的执行权限,这正是您所描述的(/data/data/%package%/).

When targeting API 29 (Android 10 / Q) or above, it is not possible anymore to have execute permission for files stored within the app's home directory (data), which is exactly what you are describing (/data/data/%package%/).

此Android 10修改是在commit中引入的: https://android-review.googlesource.com/c/platform/system/sepolicy/+/804149 ,然后由Google在此处正式确认:

This Android 10 modification was introduced in commit: https://android-review.googlesource.com/c/platform/system/sepolicy/+/804149 and was then confirmed officially by Google here: https://issuetracker.google.com/issues/128554619

各个项目正在 termux/termux-app#中讨论此重大更改.例如1072 .一种推荐的且(希望)面向未来的方法是将程序二进制文件提取到应用程序的本机lib目录中(使用android:extractNativeLibs = true),在该文件中仍可以执行文件,但对于增强了安全性.

This significant change is being discussed by various projects, in termux/termux-app#1072 for instance. One recommended and (hopefully) future-proof way is to extract program binaries into the application's native lib directory (with android:extractNativeLibs=true), where files can still be executed but are stored read-only for improved security.

以下示例显示了如何在Termux中使用提交 f6c3b6f 在android-10分支或此其他项目中显示如何在Android上运行Erlang运行时通过将.zip存档中的所有文件解压缩到 jniLibs/"abi" 子目录("abi"是用于64位ARM的arm64-v8a,用于32位的armeabi-v7a位ARM等),并具有Android平台要求的 lib ___.so文件名格式.可执行文件可以简单地手动移动到正确的项目文件夹中,重要的部分是对文件名使用lib___.so格式.

Here are examples showing how to handle this change, in Termux with commit f6c3b6f in the android-10 branch or in this other project showing how to run the Erlang runtime on Android by exctrating all the files from a .zip archive into the jniLibs/"abi" subdirectory ("abi" being arm64-v8a for 64-bit ARM, armeabi-v7a for 32-bit ARM, etc.) with the imposed lib___.so filename format expected by the Android platform. Executable files can simply be moved in the right project folder manually, the important part is to use the lib___.so format for the filenames.

在Android清单文件中,设置属性android:extractNativeLibs ="true"将在安装时从正确的本机lib目录中提取这些lib___.so文件,并支持执行权限.最终,如果需要,可以在常规应用程序目录中创建符号链接以使用常规可执行文件名称,而不是难以操作的lib___.so版本.

In the Android Manifest file, setting the attribute android:extractNativeLibs="true" will get these lib___.so files extracted at installation time in the right native lib directory, with support for execute permission. Symlinks can finally be created if needed in the usual app directory to use the regular executable names, instead of the harder-to-manipulate lib___.so versions.

谢谢,杰罗姆

这篇关于如何将可执行文件放在Android 29上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆