I have updated OpenCV module dependencies from 3.4.3 to 4.1.1 and blob color detection sample that works correctly with previous version now freezes with a black screen. I know, I can just use the newer sample code, but I want to understand why a very simple code sample that compiles correctly and works without any problem with the previous version now has this weird problem.
Watching the log isn't clear the cause of the issue seems that native libs loads correctly and then crashes.
The OpenCV log is:
2019-09-12 00:49:16.633 2080-5773/? I/ActivityTaskManager: START u0 {cmp=com.mysite.myapp/.OpenCVTestActivity} from uid 10188
I/MainActivity: Instantiated new class com.mysite.myapp.OpenCVTestActivity
D/OpenCV/StaticHelper: Trying to get library list
E/OpenCV/StaticHelper: OpenCV error: Cannot load info library for OpenCV
D/OpenCV/StaticHelper: Library list: ""
D/OpenCV/StaticHelper: First attempt to load libs
D/OpenCV/StaticHelper: Trying to init OpenCV libs
D/OpenCV/StaticHelper: Trying to load library opencv_java4
D/OpenCV/StaticHelper: Library opencv_java4 loaded
D/OpenCV/StaticHelper: First attempt to load libs is OK
I/OpenCV/StaticHelper: General configuration for OpenCV 4.1.1 =====================================
I/OpenCV/StaticHelper: Version control: 4.1.1
I/OpenCV/StaticHelper: Platform:
I/OpenCV/StaticHelper: Timestamp: 2019-07-26T03:58:21Z
I/OpenCV/StaticHelper: Host: Linux 4.15.0-54-generic x86_64
I/OpenCV/StaticHelper: Target: Android 1 x86_64
I/OpenCV/StaticHelper: CMake: 3.6.0-rc2
I/OpenCV/StaticHelper: CMake generator: Ninja
I/OpenCV/StaticHelper: CMake build tool: /opt/android/android-sdk.gradle/cmake/3.6.4111459/bin/ninja
I/OpenCV/StaticHelper: Configuration: Release
I/OpenCV/StaticHelper: CPU/HW features:
I/OpenCV/StaticHelper: Baseline: SSE SSE2 SSE3
I/OpenCV/StaticHelper: requested: SSE3
I/OpenCV/StaticHelper: Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
I/OpenCV/StaticHelper: requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
I/OpenCV/StaticHelper: SSE4_1 (12 files): + SSSE3 SSE4_1
I/OpenCV/StaticHelper: SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
I/OpenCV/StaticHelper: FP16 (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
I/OpenCV/StaticHelper: AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
I/OpenCV/StaticHelper: AVX2 (26 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
I/OpenCV/StaticHelper: AVX512_SKX (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
I/OpenCV/StaticHelper: C/C++:
I/OpenCV/StaticHelper: Built as dynamic libs?: NO
I/OpenCV/StaticHelper: C++ Compiler: /opt/android/android-ndk-r18b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ (ver 7.0)
I/OpenCV/StaticHelper: C++ flags (Release): -isystem /opt/android/android-ndk-r18b/sysroot/usr/include/x86_64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG -DNDEBUG
I/OpenCV/StaticHelper: C++ flags (Debug): -isystem /opt/android/android-ndk-r18b/sysroot/usr/include/x86_64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG -g
I/OpenCV/StaticHelper: C Compiler: /opt/android/android-ndk-r18b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
I/OpenCV/StaticHelper: C flags (Release): -isystem /opt/android/android-ndk-r18b/sysroot/usr/include/x86_64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG -DNDEBUG
I/OpenCV/StaticHelper: C flags (Debug): -isystem /opt/android/android-ndk-r18b/sysroot/usr/include/x86_64-linux-android -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG -g
I/OpenCV/StaticHelper: Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot /opt/android/android-ndk-r18b/platforms/android-21/arch-x86_64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -L/opt/android/android-ndk-r18b/sources/cxx-stl/llvm-libc++/libs/x86_64 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now
I/OpenCV/StaticHelper: Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++ --sysroot /opt/android/android-ndk-r18b/platforms/android-21/arch-x86_64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -L/opt/android/android-ndk-r18b/sources/cxx-stl/llvm-libc++/libs/x86_64 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now
I/OpenCV/StaticHelper: ccache: YES
I/OpenCV/StaticHelper: Precompiled headers: NO
I/OpenCV/StaticHelper: Extra dependencies: z dl m log
I/OpenCV/StaticHelper: 3rdparty dependencies: tbb libcpufeatures ittnotify libprotobuf libjpeg-turbo libwebp libpng libtiff libjasper IlmImf quirc ippiw ippicv
I/OpenCV/StaticHelper: OpenCV modules:
I/OpenCV/StaticHelper: To be built: calib3d core dnn features2d flann highgui imgcodecs imgproc java ml objdetect photo stitching video videoio
I/OpenCV/StaticHelper: Disabled: world
I/OpenCV/StaticHelper: Disabled by dependency: -
I/OpenCV/StaticHelper: Unavailable: gapi js python2 python3 ts
I/OpenCV/StaticHelper: Applications: -
I/OpenCV/StaticHelper: Documentation: NO
I/OpenCV/StaticHelper: Non-free algorithms: NO
I/OpenCV/StaticHelper: Android NDK: /opt/android/android-ndk-r18b (ver 18.1.5063045)
I/OpenCV/StaticHelper: Android ABI: x86_64
I/OpenCV/StaticHelper: NDK toolchain: x86_64-linux-android-clang
I/OpenCV/StaticHelper: STL type: c++_shared
I/OpenCV/StaticHelper: Native API level: 21
I/OpenCV/StaticHelper: Android SDK: /opt/android/android-sdk.gradle (tools: 26.1.1 build tools: 28.0.3)
I/OpenCV/StaticHelper: GUI:
I/OpenCV/StaticHelper: Media I/O:
I/OpenCV/StaticHelper: ZLib: z (ver 1.2.7)
I/OpenCV/StaticHelper: JPEG: build-libjpeg-turbo (ver 2.0.2-62)
I/OpenCV/StaticHelper: WEBP: build (ver encoder: 0x020e)
I/OpenCV/StaticHelper: PNG: build (ver 1.6.37)
I/OpenCV/StaticHelper: TIFF: build (ver 42 - 4.0.10)
I/OpenCV/StaticHelper: JPEG 2000: build (ver 1.900.1)
I/OpenCV/StaticHelper: OpenEXR: build (ver 2.3.0)
I/OpenCV/StaticHelper: HDR: YES
I/OpenCV/StaticHelper: SUNRASTER: YES
I/OpenCV/StaticHelper: PXM: YES
I/OpenCV/StaticHelper: PFM: YES
I/OpenCV/StaticHelper: Video I/O:
I/OpenCV/StaticHelper: Parallel framework: TBB (ver 2019.0 interface 11008)
I/OpenCV/StaticHelper: Trace: YES (with Intel ITT)
I/OpenCV/StaticHelper: Other third-party libraries:
I/OpenCV/StaticHelper: Intel IPP: 2019.0.0 Gold [2019.0.0]
I/OpenCV/StaticHelper: at: /build/master_pack-android/build/o4a/3rdparty/ippicv/ippicv_lnx/icv
I/OpenCV/StaticHelper: Intel IPP IW: sources (2019.0.0)
I/OpenCV/StaticHelper: at: /build/master_pack-android/build/o4a/3rdparty/ippicv/ippicv_lnx/iw
I/OpenCV/StaticHelper: Custom HAL: NO
I/OpenCV/StaticHelper: Protobuf: build (3.5.1)
I/OpenCV/StaticHelper: Python (for build): /usr/bin/python2.7
I/OpenCV/StaticHelper: Java: export all functions
I/OpenCV/StaticHelper: ant: NO
I/OpenCV/StaticHelper: Java wrappers: YES
I/OpenCV/StaticHelper: Java tests: NO
I/OpenCV/StaticHelper: Install to: /build/master_pack-android/build/o4a/install
I/OpenCV/StaticHelper: -----------------------------------------------------------------
D/MainActivity: OpenCV library found inside package. Using it!
I/MainActivity: OpenCV loaded successfully
I/MainActivity: OpenCV incompatible version
I/MainActivity: OpenCV init failed
I/MainActivity: OpenCV instal canceled
I/MainActivity: OpenCV market error
2019-09-12 00:49:16.893 4784-5050/com.mysite.myapp D/FA: Logging event (FE): screen_view(_vs), Bundle[{ga_event_origin(_o)=auto, ga_previous_class(_pc)=HomeActivity, ga_previous_id(_pi)=9180441033856651121, ga_screen_class(_sc)=OpenCVTestActivity, ga_screen_id(_si)=9180441033856651127}]
2019-09-12 00:49:17.221 2826-5054/? V/FA-SVC: Logging event: origin=auto,name=screen_view(_vs),params=Bundle[{ga_event_origin(_o)=auto, ga_previous_class(_pc)=HomeActivity, ga_previous_id(_pi)=9180441033856651121, ga_screen_class(_sc)=OpenCVTestActivity, ga_screen_id(_si)=9180441033856651127}]
2019-09-12 00:49:17.242 2826-5054/? V/FA-SVC: Event recorded: Event{appId='com.mysite.myapp', name='screen_view(_vs)', params=Bundle[{ga_event_origin(_o)=auto, ga_previous_class(_pc)=HomeActivity, ga_previous_id(_pi)=9180441033856651121, ga_screen_class(_sc)=OpenCVTestActivity, ga_screen_id(_si)=9180441033856651127}]}