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" } } }
发表评论