1、在主工程的local.properties中添加ndk信息,如
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed Oct 27 10:02:55 CST 2021
ndk.dir=C\:\\android-ndk-r13b\\android-ndk-r13b//该行代码与JNI有关系
sdk.dir=C\:\\Users\\Admin\\AppData\\Local\\Android\\Sdk
2、在子工程的**\build.gradle修改
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
buildToolsVersion rootProject.ext.androidBuildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.releaseVersionCode
versionName rootProject.ext.releaseVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
//JNI 相关 begin
ndk {
//abiFilters "armeabi-v7a","arm64-v8a","armeabi"
abiFilters "armeabi-v7a"
}
externalNativeBuild {
ndkBuild {
targets "imobilevideomediaengineapijava", "cpufeatures", "mbhwengine-audio"
// arguments "NDK_APPLICATION_MK:=Application.mk"
// cFlags "-DTEST_C_FLAG1", "-DTEST_C_FLAG2"
// cppFlags "-DTEST_CPP_FLAG2", "-DTEST_CPP_FLAG2"
// abiFilters "armeabi-v7a", "armeabi"
}
}
//JNI 相关 end
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
//JNI 相关 begin
sourceSets {
main {
// jniLibs.srcDirs = ['libs']
jni.srcDirs = ['src/main/jni', 'src/main/jni/']
}
}
packagingOptions {
exclude 'lib/armeabi-v7a/libcetc-log.so'
exclude 'lib/armeabi-v7a/libcetc-media-ffmpeg.so'
exclude 'lib/armeabi-v7a/libcetc-media-codec.so'
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
//JNI 相关 end
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation project(':cameramodule')
implementation project(':webrtcagc')
implementation project(':common')
implementation files('libs/webrtc-apm-release.aar')
}