Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一个可能的bug:关于64位系统运行32位的library #178

Open
heagoo opened this issue May 3, 2016 · 3 comments
Open

一个可能的bug:关于64位系统运行32位的library #178

heagoo opened this issue May 3, 2016 · 3 comments

Comments

@heagoo
Copy link

heagoo commented May 3, 2016

Class:
com.morgoo.helper.compat.NativeLibraryHelperCompat

问题:原来的代码使得VM64无法安装32bit的library,但很多VM64的手机是可以运行32bit库的

参见下面的修改:

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static int copyNativeBinariesAfterL(File apkFile, File sharedLibraryDir) {
try {
Object handleInstance = MethodUtils.invokeStaticMethod(handleClass(), "create", apkFile);
if (handleInstance == null) {
return -1;
}

        String abi = null;

        if (isVM64()) {
            if (Build.SUPPORTED_64_BIT_ABIS.length > 0) {
                Set<String> abis = getAbisFromApk(apkFile.getAbsolutePath());
                if (abis == null || abis.isEmpty()) {
                    return 0;
                }

                for (String item : Build.SUPPORTED_64_BIT_ABIS) {
                    abis.add(item);
                }
                String[] supportedAbis = new String[abis.size()];
                supportedAbis = abis.toArray(supportedAbis);

                int abiIndex = (int) MethodUtils.invokeStaticMethod(nativeLibraryHelperClass(), "findSupportedAbi", handleInstance, supportedAbis);
                if (abiIndex >= 0) {
                    abi = supportedAbis[abiIndex];
                }
            }
        } else {
            if (Build.SUPPORTED_32_BIT_ABIS.length > 0) {
                Set<String> abis = getAbisFromApk(apkFile.getAbsolutePath());
                if (abis == null || abis.isEmpty()) {
                    return 0;
                }

                for (String item : Build.SUPPORTED_32_BIT_ABIS) {
                    abis.add(item);
                }
                String[] supportedAbis = new String[abis.size()];
                supportedAbis = abis.toArray(supportedAbis);

                int abiIndex = (int) MethodUtils.invokeStaticMethod(nativeLibraryHelperClass(), "findSupportedAbi", handleInstance, supportedAbis);
                if (abiIndex >= 0) {
                    abi = supportedAbis[abiIndex];
                }
            }
        }
@JackCho
Copy link
Contributor

JackCho commented May 3, 2016

@heagoo 64位手机是可以兼容32位的library,但这是有个条件的,就是在运行之前,系统会检测libs中是否只有arm,而非arm64-v8a。所以如果你的宿主运行中有arm64-v8a的话,那么进程就是以64位去运行的,但是你的插件里面只有32为的arm so包的话,是不能安装的,因为安装运行也会失败

@JackCho
Copy link
Contributor

JackCho commented May 3, 2016

看下这个PR #170

@heagoo
Copy link
Author

heagoo commented May 4, 2016

谢谢解惑!

On Tue, May 3, 2016 at 6:55 PM, jack_1900 [email protected] wrote:

看下这个PR #170 #170


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#178 (comment)

"The first step is as good as half over."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants