mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 19:24:07 +08:00

Android builds update #26057 Fixes https://github.com/opencv/opencv/issues/26027 Should also address https://github.com/opencv/opencv/issues/26542 Changes: - Switched to Android build tools 34, NDK 26d, target API level 34 (required by Google Play). - Use flexible page size on Android by default to support Android 15+. - Dummy stub for R and BuildConfig classes for javadoc. - Java 17 everywhere. - Strict ndkVersion and ABI list in release package. Related: - Docker: https://github.com/opencv-infrastructure/opencv-gha-dockerfile/pull/41 - Pipeline: https://github.com/opencv/ci-gha-workflow/pull/183 Related IPP issue with NDK 27+: https://github.com/opencv/opencv/issues/26072 Google documentation for 16kb pages support : https://developer.android.com/guide/practices/page-sizes?hl=en ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
63 lines
2.2 KiB
Groovy
63 lines
2.2 KiB
Groovy
apply plugin: 'com.android.application'
|
|
|
|
android {
|
|
namespace 'org.opencv.samples.tutorial2'
|
|
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@
|
|
defaultConfig {
|
|
applicationId "org.opencv.samples.tutorial2"
|
|
minSdkVersion @ANDROID_MIN_SDK_VERSION@
|
|
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
|
|
versionCode 301
|
|
versionName "3.01"
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
if (gradle.opencv_source == "sdk_path") {
|
|
arguments "-DOpenCV_DIR=" + project(':opencv').projectDir + "/@ANDROID_PROJECT_JNI_PATH@",
|
|
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
|
|
"-DOPENCV_FROM_SDK=TRUE"@OPENCV_ANDROID_CMAKE_EXTRA_ARGS@
|
|
} else {
|
|
arguments "-DOPENCV_VERSION_MAJOR=@OPENCV_VERSION_MAJOR@",
|
|
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
|
|
"-DOPENCV_FROM_SDK=FALSE"@OPENCV_ANDROID_CMAKE_EXTRA_ARGS@
|
|
}
|
|
targets "mixed_sample"
|
|
}
|
|
}
|
|
}
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
}
|
|
sourceSets {
|
|
main {
|
|
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@
|
|
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@
|
|
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@'
|
|
}
|
|
}
|
|
externalNativeBuild {
|
|
cmake {
|
|
path '@ANDROID_SAMPLE_JNI_PATH@/CMakeLists.txt'
|
|
}
|
|
}
|
|
buildFeatures {
|
|
if (gradle.opencv_source == "maven_local" || gradle.opencv_source == "maven_central") {
|
|
prefab true
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
//implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
if (gradle.opencv_source == "sdk_path") {
|
|
println 'Using OpenCV from SDK'
|
|
implementation project(':opencv')
|
|
} else if (gradle.opencv_source == "maven_local" || gradle.opencv_source == "maven_central") {
|
|
println 'Using OpenCV from Maven repo'
|
|
implementation 'org.opencv:opencv:@OPENCV_VERSION_PLAIN@'
|
|
}
|
|
}
|