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.

Community
  • 1
  • 1
Umesh Aawte
  • 4,590
  • 7
  • 41
  • 51

2 Answers2

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.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • 1
    yes, you are correct some if the packages are with 64 bit libraries. Trying your solution – Umesh Aawte Nov 26 '15 at 07:30
  • @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. – Madhan Jan 17 '17 at 13:34
  • @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. – Alex Cohn Jan 17 '17 at 14:28
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.

Jared Rummler
  • 37,824
  • 19
  • 133
  • 148