"dlopen失败:是32位而不是64位".仅在测试中 [英] "dlopen failed: is 32-bit instead of 64-bit" in tests only

查看:704
本文介绍了"dlopen失败:是32位而不是64位".仅在测试中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个set或Gradle模块,它们使用基于c ++代码的核心模块:

I'm having a set or Gradle modules that uses the core module based on c++ code:

  • 核心(带有JNI胶的C ++,带有libxyz-jni.soaar)
  • 测试(Android工具测试)
  • 应用(常规的Android应用)
  • Core (C++ with JNI glue, aar with libxyz-jni.so)
  • Tests (Android instrumentation tests)
  • App (regular Android app)

Core模块包括为armeabi-v7ax86编译的本机32位libxyz-jni.so,并已编译为aar.它没有arm64库.

Core module includes native 32 bit libxyz-jni.so compiled for armeabi-v7a and x86 and is compiled to aar. It does not have arm64 libraries.

App模块取决于Core,并且可以在arm64硬件设备上正常运行(可以加载libxyz-jni.so)

App module depends on Core and is working on arm64 hardware device without any issues (is able to load libxyz-jni.so)

Tests依赖于Core,并且由于以下错误而无法加载libxyz-jni.so(带有System.loadLibrary(..)):

Tests depends on Core and fails to load libxyz-jni.so (with System.loadLibrary(..)) with following error:

java.lang.UnsatisfiedLinkError:dlopen失败:"/data/app/package.tests.test-2/lib/arm/libxyz-jni.so"是32位而不是64位.

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/package.tests.test-2/lib/arm/libxyz-jni.so" is 32-bit instead of 64-bit.

我已经检查了测试apk,其中除了armeabi-v7ax86以外没有其他任何拱门.这些测试可以在android模拟器中运行,但不能在具有Android Nougat的64位硬件设备上运行.该应用程序可以在arm64设备上运行.

I've checked tests apk not to contain any arch except armeabi-v7a and x86. The tests can run in android emulator but can't on 64 bit hardware device with Android Nougat. The App can run on arm64 device.

就加载库而言,测试和应用程序之间的区别是什么?

That's the difference between tests and app in terms of loading library?

推荐答案

您应检查运行时应用程序正在使用哪些库.您可以使用以下命令执行此操作:

You should check to see what libraries your app is using at runtime. You can do this with these commands:

# get your running pid
adb shell ps | grep <your package name> | tr -s ' ' |  cut -d ' ' -f 2 
32333
adb shell lsof | grep 32333 | grep so
.xxx 32333    u0_a222  mem       REG             259,30    133152       2629 /system/lib64/libcompiler_rt.so
.xxx 32333    u0_a222  mem       REG             259,30     30824       2759 /system/lib64/libmemalloc.so

在这种情况下,您可以看到Android已加载lib64库.如果您希望默认情况下加载32位库,则需要在 APK 中包含lib/armeabi-v7a/lib.so.

As you can see in this case Android has loaded lib64 libraries. If you want it to default to loading 32-bit libraries, you need to have lib/armeabi-v7a/lib.so in your APK.

如果您的库在APK中位于其他位置,并且您提取并动态加载,则Android不会知道它们是32位的.

If you have your libraries somewhere else in the APK, and you extract, and load dynamically, Android won't know they are 32bit.

这篇关于"dlopen失败:是32位而不是64位".仅在测试中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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