INSTALL_FAILED_MISSING_SHARED_LIBRARY ทำให้แอปไม่ติดตั้ง

Oct 15 2020

ฉันได้รับข้อผิดพลาด

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

ลิงก์นำฉันไปยังหน้าที่มีบันทึกประจำรุ่นสำหรับ Android 4.2 ดังนั้นจึงไม่มีปัญหาใด ๆ เกิดขึ้นก่อน

ฉันใช้ไลบรารี Documentscanner buitl กับ opencv และใช้ jnilibs และปัญหาที่ฉันมีคือ jnilibs นั้น

ดังนั้น

ฉันดูคู่มือนักพัฒนา Android และเจอสิ่งนี้

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.

ตอนนี้หลังจากทำตาม IE ด้านบนการย้ายไลบรารี / ลบออกจาก gradle.build ของฉันเป็นต้นแอปสร้างและเริ่มติดตั้ง แต่แล้วฉันก็ได้รับข้อผิดพลาด

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

ความช่วยเหลือจะได้รับการชื่นชม

คำตอบ

mayank1513 Oct 28 2020 at 10:47

โปรดทำตามคำตอบนี้

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

หากคุณใช้ Android Gradle Plugin 4.0 ให้ย้ายไลบรารีใด ๆ ที่ใช้โดย IMPORTED CMake เป้าหมายออกจากไดเร็กทอรี jniLibs ของคุณเพื่อหลีกเลี่ยงข้อผิดพลาดนี้

ดังนั้นคุณจะต้องย้ายโฟลเดอร์ $ {ANDROID_ABI} /libdlib.so ไปยังที่อื่นเช่นสร้างชื่อไดเรกทอรีใหม่ cmakeLibs

เช่น:

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

อ้างอิง - https://developer.android.com/studio/projects/gradle-external-native-builds#jniLibs

RubenMeiring Dec 11 2020 at 13:43

ฉันได้แก้ไขปัญหานี้โดยการนำเข้าโมดูล opencv ล่าสุดด้วยตนเองปัญหาคือ opencv ที่รวมอยู่ในไลบรารีที่ฉันใช้นั้นล้าสมัย

หากคุณได้รับข้อผิดพลาดเดียวกัน (หรือฉันขอแนะนำให้ทำเช่นนี้หากคุณมีปัญหากับ opencv)

นี่คือวิธีที่ฉันแก้ไข

ลบไลบรารีและโมดูลทั้งหมดที่เกี่ยวข้องกับข้อผิดพลาด (Opencv ฯลฯ )

จากนั้นดาวน์โหลดโมดูล android openCV และนำเข้า

จากนั้นนำเข้าไลบรารีที่ใช้ openCV (ในกรณีของฉันมันคือ AndroidScannerDemo โดย jhansireddy บน github)

และสุดท้ายปรับรหัสของคุณเพื่อใช้ไลบรารีที่คุณใช้