Android开发之AndroidStudio兼容第三方库和自定义库

1.在CMakeLists.txt中设置自定义库的加载路径,不要和第三方库的路径一致,否则每次编译都会删掉第三方库
CMakeList.txt:

......
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/jniLibs/${ANDROID_ABI})
......

2.在模块的build.gradle中设置第三方库的加载路径:

android {
......
	    defaultConfig {
	    ......
	    	ndk {
           		// Specifies the ABI configurations of your native
            	// libraries Gradle should build and package with your APK.
            	abiFilters 'armeabi-v7a','arm64-v8a'
        	}
        	sourceSets.main.jniLibs.srcDirs = ['libs']
	    ......
		}
......
}

你可能感兴趣的:(Android知识汇总)