Skip to content

[opencv_core] & [opencv_dart] with android auto ignore unuse abi #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/opencv_core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.history
.svn/
migrate_working_dir/
.cxx/

# IntelliJ related
*.iml
Expand Down
132 changes: 78 additions & 54 deletions packages/opencv_core/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,86 +1,110 @@
// The Android Gradle Plugin builds the native code with the Android NDK.

group = "dev.rainyl.opencv_core"
version = "1.0"
group = 'dev.rainyl.opencv_core'
version = '1.0'

buildscript {
repositories {
google()
mavenCentral()
}
repositories {
google()
mavenCentral()
}

dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath("com.android.tools.build:gradle:8.1.0")
}
dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath('com.android.tools.build:gradle:8.1.0')
}
}

rootProject.allprojects {
repositories {
google()
mavenCentral()
}
repositories {
google()
mavenCentral()
}
}

apply plugin: "com.android.library"
apply plugin: 'com.android.library'

def SOURCE_DIR = project.buildscript.sourceFile.parentFile

android {
if (project.android.hasProperty("namespace")) {
namespace = "dev.rainyl.opencv_core"
if (project.android.hasProperty('namespace')) {
namespace = 'dev.rainyl.opencv_core'
}

// Bumping the plugin compileSdk version requires all clients of this plugin
// to bump the version in their app.
compileSdk = 33

// Use the NDK version
// declared in /android/app/build.gradle file of the Flutter project.
// Replace it with a version number if this plugin requires a specific NDK version.
// (e.g. ndkVersion "23.1.7779620")
// ndkVersion = android.ndkVersion

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path = '../src/CMakeLists.txt'

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}

// Bumping the plugin compileSdk version requires all clients of this plugin
// to bump the version in their app.
compileSdk = 33
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

// Use the NDK version
// declared in /android/app/build.gradle file of the Flutter project.
// Replace it with a version number if this plugin requires a specific NDK version.
// (e.g. ndkVersion "23.1.7779620")
// ndkVersion = android.ndkVersion
defaultConfig {
minSdkVersion 24

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path = "../src/CMakeLists.txt"

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
cmake {
arguments '-DANDROID_ARM_NEON=TRUE',
'-DANDROID_STL=c++_static',
"-DCMAKE_INSTALL_PREFIX=$SOURCE_DIR/src/main/jniLibs"
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildTypes {
release {
externalNativeBuild {
cmake {
arguments '-DCMAKE_BUILD_TYPE=Release'
}
}

defaultConfig {
minSdkVersion 24
def targetPlatforms = project.getProperty('target-platform').split(',') as List
if (!targetPlatforms.isEmpty()) {
def platformAbiMap = [
'android-arm64': 'arm64-v8a',
'android-arm' : 'armeabi-v7a',
'android-x86' : 'x86',
'android-x64' : 'x86_64'
]

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
arguments "-DANDROID_ARM_NEON=TRUE",
"-DANDROID_STL=c++_static",
"-DCMAKE_INSTALL_PREFIX=$SOURCE_DIR/src/main/jniLibs"
def excludeList = platformAbiMap.values() as List

targetPlatforms.each { platform ->
excludeList.remove(platformAbiMap[platform])
}
}

buildTypes {
release {
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=Release"
logger.info "[OPENCV_CORE] building for platforms: $targetPlatforms"
logger.info "[OPENCV_CORE] excluded abis: $excludeList"
packagingOptions {
excludeList.each { abi ->
exclude "lib/$abi/*"
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions packages/opencv_dart/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.history
.svn/
migrate_working_dir/
.cxx/

# IntelliJ related
*.iml
Expand Down
128 changes: 76 additions & 52 deletions packages/opencv_dart/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,106 @@ group 'dev.rainyl.opencv_dart'
version '1.0'

buildscript {
repositories {
google()
mavenCentral()
}
repositories {
google()
mavenCentral()
}

dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath("com.android.tools.build:gradle:8.1.0")
}
dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath("com.android.tools.build:gradle:8.1.0")
}
}

rootProject.allprojects {
repositories {
google()
mavenCentral()
}
repositories {
google()
mavenCentral()
}
}

apply plugin: 'com.android.library'

def SOURCE_DIR = project.buildscript.sourceFile.parentFile

android {
if (project.android.hasProperty("namespace")) {
namespace 'dev.rainyl.opencv_dart'
if (project.android.hasProperty("namespace")) {
namespace 'dev.rainyl.opencv_dart'
}

// Bumping the plugin compileSdk version requires all clients of this plugin
// to bump the version in their app.
compileSdk 33

// Use the NDK version declared in /android/app/build.gradle file of the Flutter project.
// Replace it with a version number if this plugin requires a specific NDK version.
// (e.g. ndkVersion "23.1.7779620")
// ndkVersion = android.ndkVersion

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path "../src/CMakeLists.txt"

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}

// Bumping the plugin compileSdk version requires all clients of this plugin
// to bump the version in their app.
compileSdk 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// Use the NDK version declared in /android/app/build.gradle file of the Flutter project.
// Replace it with a version number if this plugin requires a specific NDK version.
// (e.g. ndkVersion "23.1.7779620")
// ndkVersion = android.ndkVersion
defaultConfig {
minSdkVersion 24

// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
cmake {
path "../src/CMakeLists.txt"

// The default CMake version for the Android Gradle Plugin is 3.10.2.
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
//
// The Flutter tooling requires that developers have CMake 3.10 or later
// installed. You should not increase this version, as doing so will cause
// the plugin to fail to compile for some customers of the plugin.
// version "3.10.2"
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
cmake {
arguments "-DANDROID_ARM_NEON=TRUE",
"-DANDROID_STL=c++_static",
"-DCMAKE_INSTALL_PREFIX=$SOURCE_DIR/src/main/jniLibs"
}
}

defaultConfig {
minSdkVersion 24

// Invoke the shared CMake build with the Android Gradle Plugin.
buildTypes {
release {
externalNativeBuild {
cmake {
arguments "-DANDROID_ARM_NEON=TRUE",
"-DANDROID_STL=c++_static",
"-DCMAKE_INSTALL_PREFIX=$SOURCE_DIR/src/main/jniLibs"
}
cmake {
arguments "-DCMAKE_BUILD_TYPE=Release"
}
}

buildTypes {
release {
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=Release"
}
def targetPlatforms = project.getProperty('target-platform').split(',') as List
if (!targetPlatforms.isEmpty()) {
def platformAbiMap = [
'android-arm64': 'arm64-v8a',
'android-arm' : 'armeabi-v7a',
'android-x86' : 'x86',
'android-x64' : 'x86_64'
]

def excludeList = platformAbiMap.values() as List

targetPlatforms.each { platform ->
excludeList.remove(platformAbiMap[platform])
}

logger.info "[OPENCV_DART] building for platforms: $targetPlatforms"
logger.info "[OPENCV_DART] excluded abis: $excludeList"
packagingOptions {
excludeList.each { abi ->
exclude "lib/$abi/*"
}
}
}
}
}
}
}