Fresco: Native libraries missing after integration with fresco

Created on 10 Jun 2015  路  5Comments  路  Source: facebook/fresco

Hi,

I am trying to integrate fresco (0.5.1) on existing project with pre-build .so libraries. I found original .so files are no longer available in nativeLibraryPath (e.g. /data/app-lib/{PACKAGE_NAME}-N)

I found similar thread related to this https://github.com/facebook/fresco/issues/264, yet unable to get it work with creating the missing directories.

build

Most helpful comment

a common issue with native libs on Android is that if one native lib is available for an abi then all your native libs need to be available for that abi, it won't fall back to a lower supporting abi, so x86_64 won't fall back to x86

I had to put in this

    packagingOptions {
        exclude "lib/armeabi/libbitmaps.so"
        exclude "lib/armeabi/libgifimage.so"
        exclude "lib/armeabi/libimagepipeline.so"
        exclude "lib/armeabi/libmemchunk.so"
        exclude "lib/armeabi/libwebp.so"
        exclude "lib/armeabi/libwebpimage.so"
        exclude "lib/arm64-v8a/libbitmaps.so"
        exclude "lib/arm64-v8a/libgifimage.so"
        exclude "lib/arm64-v8a/libimagepipeline.so"
        exclude "lib/arm64-v8a/libmemchunk.so"
        exclude "lib/arm64-v8a/libwebp.so"
        exclude "lib/arm64-v8a/libwebpimage.so"
        exclude "lib/x86_64/libbitmaps.so"
        exclude "lib/x86_64/libgifimage.so"
        exclude "lib/x86_64/libimagepipeline.so"
        exclude "lib/x86_64/libmemchunk.so"
        exclude "lib/x86_64/libwebp.so"
        exclude "lib/x86_64/libwebpimage.so"
    }

in the android section of my build.gradle file

to allow a single apk build to work - though the better solution is to produce abi splits

All 5 comments

What does your build.gradle file look like?

build.gradle

 dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile project(":VideoRecorder")
        compile "com.android.support:appcompat-v7:21.0.+"
    }

directory structure of library project VideoRecorder

  • build.gradle
  • app/
  • --- libs/
  • ------ javacpp.jar
  • ------ javacv.jar
  • --- src/
  • ------ main/
  • --------- jniLibs/armeabi/*.so

build.gradle of VideoRecorder

buildscript {
    repositories {
        jcenter()
    }   
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.2'
    }   
}

allprojects {
    repositories {
        jcenter()
    }   
}

./app/build.gradle of VideoRecorder

apply plugin: 'android-library'

group = 'common.shared'
version = '1.0.0'
archivesBaseName = 'VideoRecorder'

android {
    compileSdkVersion 17
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 17
    }   
}
dependencies {
    compile 'com.android.support:support-v4:+'
    compile files('libs/javacpp.jar')
    compile files('libs/javacv.jar')
}

We found all .so files are present in the apk file after unzipping with apktool, yet some of them can't be copied to devices nativeLibraryPath for some reason. Any clue for that?

Yet we managed to get the .so libraries included correctly by making separated apks (ref. http://frescolib.org/docs/multiple-apks.html)

a common issue with native libs on Android is that if one native lib is available for an abi then all your native libs need to be available for that abi, it won't fall back to a lower supporting abi, so x86_64 won't fall back to x86

I had to put in this

    packagingOptions {
        exclude "lib/armeabi/libbitmaps.so"
        exclude "lib/armeabi/libgifimage.so"
        exclude "lib/armeabi/libimagepipeline.so"
        exclude "lib/armeabi/libmemchunk.so"
        exclude "lib/armeabi/libwebp.so"
        exclude "lib/armeabi/libwebpimage.so"
        exclude "lib/arm64-v8a/libbitmaps.so"
        exclude "lib/arm64-v8a/libgifimage.so"
        exclude "lib/arm64-v8a/libimagepipeline.so"
        exclude "lib/arm64-v8a/libmemchunk.so"
        exclude "lib/arm64-v8a/libwebp.so"
        exclude "lib/arm64-v8a/libwebpimage.so"
        exclude "lib/x86_64/libbitmaps.so"
        exclude "lib/x86_64/libgifimage.so"
        exclude "lib/x86_64/libimagepipeline.so"
        exclude "lib/x86_64/libmemchunk.so"
        exclude "lib/x86_64/libwebp.so"
        exclude "lib/x86_64/libwebpimage.so"
    }

in the android section of my build.gradle file

to allow a single apk build to work - though the better solution is to produce abi splits

I'll leave this comment here for the people that might run into my same problem.

I have an app that uses both Fresco and Unity 3D (through a UnityPlayerActivity).

The Unity activity was crashing with the error "unable to find main". I noticed this only happened in devices with arm64-v8a.

Adding what @kassim said to the build.gradle file fixed the problem.

Was this page helpful?
0 / 5 - 0 ratings