Can not find .so file on 64 bit android device
Asked Answered
H

2

6

Using aviary android sdk using android studio and gradle build. App generated running fine on all devices having 32 bit architecture.

Same app is giving following error in the 64 bit device [Eg. Sony 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 part

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'
}

Reference That did not worked

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

Same error if use any of solution used.

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

Getting error like

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.

I am not sure what wrong I am doing or it is not supported at all.

Hazel answered 25/11, 2015 at 11:52 Comment(2)
Do you have native libs that you build yourself, or only imported from external sources?Idempotent
Imported from external source that is of adobe creativesdkHazel
I
20

It looks like some of the packages you use come with 64-bit libraries, but some don't. To keep your APK 32-bit only, I use

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

You can play with include 'armeabi' too, if it is relevant.

Idempotent answered 25/11, 2015 at 23:23 Comment(3)
yes, you are correct some if the packages are with 64 bit libraries. Trying your solutionHazel
@Alex Cohn: Could you please tell me how to find which libraries are 64-bit and which are 32-bit in my app? Because, by using the above closure, my problem is solved. I used only one library and I don't know which other libraries raise this error.Samovar
@Madhan: this typically happens when you use prebuilt libraries. You will find files build/intermediates/exploded-aar/??/jni/arm64-v8a/lib???.so. Also instead of arm64-v8a you could see x86_64. You can safely remove these libraries from your APK.Idempotent
C
7

I've solved this case by the following steps:

  1. I've moved armeabi and x86 folders from: \src\main\jniLibs to: \libs

    Please make sure to move all the files under those folders as well: *.so files should be located there.

  2. I've added the following to my build.gradle:

    sourceSets.main {
      jniLibs.srcDir 'src/main/libs'
    }
    
  3. Clean + rebuild the project

    *in case you are using multidex, please verify that these lines were added to build.gradle:

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

In addition, this should be added inside your manifest file:

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

Hope this helps.

Cleveite answered 29/2, 2016 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.