INSTALL_FAILED_MISSING_SHARED_LIBRARY Causes app to not install

Viewed 352

I was getting the error

More than one file was found with OS independent path 'lib/x86_64/libopencv_java3.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

the link takes me to a page with a release notes for android 4.2, so there is nothing pretaining to my problem,

I am using a Documentscanner library buitl with opencv and that uses jnilibs and the problem I have is with that jnilibs

so

I looked through the Android Dev Guide and came across this

Automatic packaging of prebuilt dependencies used by CMake
Prior versions of the Android Gradle Plugin required that you explicitly package any prebuilt libraries used by your CMake external native build by using jniLibs. You may have libraries in the src/main/jniLibs directory of your module, or possibly in some other directory configured in your build.gradle file:

    sourceSets {
        main {
            // The libs directory contains prebuilt libraries that are used by the
            // app's library defined in CMakeLists.txt via an IMPORTED target.
            jniLibs.srcDirs = ['libs']
        }
    }

With Android Gradle Plugin 4.0, the above configuration is no longer necessary and will result in a build failure:

* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'lib/x86/libprebuilt.so'

External native build now automatically packages those libraries, so explicitly packaging the library with jniLibs results in a duplicate. To avoid the build error, move the prebuilt library to a location outside jniLibs or remove the jniLibs configuration from your build.gradle file.

So now after following the above IE Moving the library/ removing from my gradle.build etc. The app builds and starts to install but then I get the error

Installation did not succeed.
The application could not be installed: INSTALL_FAILED_MISSING_SHARED_LIBRARY

Help would be appreciated

2 Answers

Please follow this answer.

According to https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs

If you are using Android Gradle Plugin 4.0, move any libraries that are used by IMPORTED CMake targets out of your jniLibs directory to avoid this error.

So you only need to move the ${ANDROID_ABI}/libdlib.so folder to another place such as creating a new directory name cmakeLibs

eg:

set_target_properties( dlib
    PROPERTIES IMPORTED_LOCATION
    ${CMAKE_SOURCE_DIR}/../cmakeLibs/${ANDROID_ABI}/libdlib.so )

enter image description here

Refer - https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs

I have solved this by importing the latest opencv module manually, the problem was that the opencv included in the library I was using was outdated.

if you get the same error(or I would recomend doing this if you having issues with opencv)

This is how i fixed

Removed all the libraries and modules pertaining to the error(Opencv etc)

Then download openCV android module and import it

then import the library that uses openCV (In my case it was AndroidScannerDemo by jhansireddy on github)

and then lastly Adjust your code to use the library you are using

Related