diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 164fe80..1ba4037 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -23,13 +23,16 @@ set( ${CMAKE_SOURCE_DIR}/../opencv-3-4-15 ) -# register a library to import... +# register the opencv header files... +include_directories(${lib_src_dir}/native/jni/include) + +# register a new library to import... add_library( lib_opencv SHARED IMPORTED ) -# ...and assign the corresponding location of the precompiled library +# ...and assign the corresponding location of the precompiled opencv library set_target_properties( lib_opencv PROPERTIES @@ -37,22 +40,16 @@ set_target_properties( ${lib_src_dir}/native/libs/${ANDROID_ABI}/libopencv_java3.so ) -# register another library to import... +# register the custom c++ code of the app as library add_library( native_opencv SHARED - src/main/cpp/native_opencv.cpp # register the source code of the custom c++ code -) -# ...and assign the location of the c++ text files of the opencv lib -target_include_directories( - native_opencv - PRIVATE - ${lib_src_dir}/native/jni/include + src/main/cpp/native_opencv.cpp ) # link the required libs together target_link_libraries( - native_opencv # includes source code and opencv source file + native_opencv # includes the custom c++ code of the app lib_opencv # includes the precompiled opencv lib android # include android sdk log # include android logging sdk diff --git a/app/build.gradle b/app/build.gradle index 0ff6082..8135da9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,17 +10,31 @@ android { applicationId = 'com.michaeltroger.featureMatchingNative' minSdkVersion 14 targetSdkVersion 30 - versionCode = 2 - versionName = '1.1' - ndk { - abiFilters 'armeabi-v7a', 'x86' - } + versionCode = 3 + versionName = '1.2' + ndk.abiFilters 'x86', 'armeabi-v7a' + //only x86 abis specified here + //a workaround with build variants was required to allow x64 support too + //the issue was that the custom c++ code was not compiled and copied into the + //x64 apks when minsdk set to 14. x64 is supported since minsdk 21 only externalNativeBuild { cmake { cppFlags "-fexceptions", "-frtti" } } } + flavorDimensions "api" + productFlavors { + minApi14 { // default variant with only x86 support but works with all devices + dimension "api" + } + minApi21 { //choose this build variant to get x64 support (recommended on modern devices) + dimension "api" + minSdkVersion 21 + ndk.abiFilters += 'x86_64' + ndk.abiFilters += 'arm64-v8a' + } + } buildTypes { release { minifyEnabled false