rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
136 stars 18 forks source link

[Android] Support 16KB Page Size #294

Open mhdjazmati opened 22 hours ago

mhdjazmati commented 22 hours ago

Describe the bug

final img = await cv.imreadAsync(imagePath, flags: cv.IMREAD_GRAYSCALE);

when it goes here it will crash with exception:

Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'libdartcv.so': dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~6THc7nmbhNWQ1qGf0VwAkQ==/com.example.opencv_oc-Rn_I_jOHmr7ZXoEHurFG1Q==/base.apk!/lib/arm64-v8a/libdartcv.so" (new hash type from the future?)

keep in mind this is my arm64-v8a folder: libavcodec.so libavformat.so
libswresample.so libavfilter.so
libavutil.so
libswscale.so

also when i try to run the command: _dart run opencvdart:setup android -a arm64-v8a -f i got error : Could not find bin/setup.dart in package opencv_dart.

keep in mind on MacOS platform it is working

To Reproduce Steps to reproduce the behavior: just make new project add lib to pubspec, run with the example code.

Desktop (please complete the following information):

Smartphone (please complete the following information):

rainyl commented 10 hours ago

@mhdjazmati I can't reproduce it with Android API level 34, are you using Android 35?

also when i try to run the command: dart run opencv_dart:setup android -a arm64-v8a -f i got error : Could not find bin/setup.dart in package opencv_dart.

Since v1.3.0, the setup commands have been deprecated, because the libdartcv will be build locally.

Also, it would be helpful if you can attach the compiled libdartcv.so, you can find it in build/app/intermediates/stripped_native_libs/debug/out/lib/arm64-v8a

Related:

mhdjazmati commented 10 hours ago
android {
    namespace = "com.example.opencv_oc"
    compileSdk = flutter.compileSdkVersion
    ndkVersion "25.1.8937393"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = 17
    }

    defaultConfig {
        minSdk = 26
        targetSdk = 34
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        applicationId = "com.example.opencv_oc"
    }

    buildTypes {
        release {
            signingConfig = signingConfigs.debug
        }
    }
}
Screenshot 2024-11-21 at 1 15 07 PM

this is the size of it for it and i attached it as zip [Uploading libdartcv.so.zip…]()

mhdjazmati commented 10 hours ago

also my emulator api is 35

mhdjazmati commented 10 hours ago
Screenshot 2024-11-21 at 1 28 35 PM

is this the issue ? the emulator?

rainyl commented 9 hours ago

is this the issue ? the emulator?

Very likely, there are many similiar issues about 16KB page size:

rainyl commented 9 hours ago

I have reproduced the bug using API 35 with 16KB page size, will look into and try to fix it.

For now, please use emulators without 16KB Page Size