Skip to content

Commit

Permalink
Merge pull request #5 from michaeltroger/dev
Browse files Browse the repository at this point in the history
1.2
  • Loading branch information
michaeltroger authored Aug 21, 2021
2 parents 6c63046 + 6d2b466 commit b1112e9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
19 changes: 8 additions & 11 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,33 @@ 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
IMPORTED_LOCATION
${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
Expand Down
24 changes: 19 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1112e9

Please sign in to comment.