解决More than one file was found with OS independent path

2022-09-29 18:26:13  阅读 348 次 评论 0 条

NDK引用其它SO,编译报错

More than one file was found with OS independent path 'lib/armeabi-v7a/libutils.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


解决方法:在build.gradle 的android 节点下添加

    packagingOptions {exclude 'lib/armeabi-v7a/libutils.so'}

如下

android {
    compileSdkVersion 32
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.test.native"
        minSdkVersion 23
        targetSdkVersion 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11"
            }
        }

        ndk {
            abiFilters "armeabi-v7a"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    //这这这这
    packagingOptions {exclude 'lib/armeabi-v7a/libutils.so'}

//    aaptOptions {
//        noCompress "so"  //表示不让aapt压缩的文件后缀
//    }

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version "3.10.2"
        }
    }
}


本文地址:http://www.bloguan.com/?id=591
版权声明:本文为原创文章,版权归 博观网 所有,欢迎分享本文,转载请保留出处!

发表评论


表情

还没有留言,还不快点抢沙发?