【问题标题】:Can not find .so file on 64 bit android device在 64 位安卓设备上找不到 .so 文件
【发布时间】:2016-02-28 04:54:03
【问题描述】:

使用 aviary android sdk 使用 android studio 和 gradle build。 生成的应用在所有具有 32 位架构的设备上运行良好。

同一应用程序在 64 位设备中出现以下错误 [例如。索尼C4]

    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file 
"/data/app/com.myapp/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libaviary_moalite.so"

gredle.build 部分

dependencies {
    ...
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.facebook.fresco:fresco:0.8.1+'
    compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1+'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.adobe.creativesdk:image:4.0.0'
}

参考无效

Can't find ARM64 NDK native lib using Android Studio (1.3 RC)

如果使用所用的任何解决方案,都会出现同样的错误。

How to use 32-bit native libraries on 64-bit Android device

得到类似的错误

Error:(16, 0) Error: NDK integration is deprecated in the current plugin.  Consider trying the new experimental plugin.  For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental.  Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.

我不确定自己做错了什么,或者根本不支持。

【问题讨论】:

  • 您有自己构建的本机库,还是仅从外部源导入的库?
  • 从 adobe creativesdk 的外部源导入

标签: android android-ndk aviary adobecreativesdk


【解决方案1】:

看起来您使用的某些软件包带有 64 位库,但有些没有。为了使您的 APK 仅保留 32 位,我使用

android {
    splits {
        abi {
            enable true
            reset()
            include 'armeabi-v7a'
        }
    }
}

如果相关,您也可以使用include 'armeabi'

【讨论】:

  • 是的,如果软件包带有 64 位库,您是正确的。尝试您的解决方案
  • @Alex Cohn:你能告诉我如何在我的应用程序中找到哪些库是 64 位的,哪些是 32 位的?因为,通过使用上面的闭包,我的问题就解决了。我只使用了一个库,我不知道还有哪些其他库会引发此错误。
  • @Madhan:这通常发生在您使用预建库时。您将找到文件build/intermediates/exploded-aar/??/jni/arm64-v8a/lib???.so。您还可以看到 x86_64 而不是 arm64-v8a。您可以从 APK 中安全地删除这些库。
【解决方案2】:

我已经通过以下步骤解决了这个问题:

  1. 我已移动 armeabi 和 x86 文件夹 来自:\src\main\jniLibs 到:\libs

    请确保同时移动这些文件夹下的所有文件:*.so 文件应该位于那里。

  2. 我在 build.gradle 中添加了以下内容:

    sourceSets.main {
      jniLibs.srcDir 'src/main/libs'
    }
    
  3. 清理+重建项目

    *如果您使用的是 multidex,请验证这些行是否已添加到 build.gradle:

    defaultConfig {
      multiDexEnabled true
    }
    
    dexOptions {
      preDexLibraries false
      javaMaxHeapSize "4g"
    }
    

此外,这应该添加到您的清单文件中:

<application
    android:name="android.support.multidex.MultiDexApplication">
/application>

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多