Android JNI: gst_element_factory_make returns nullptr

Thank you, Joe. Here is my CMakeLists.txt

set(
    GSTREAMER_ROOT
    "/Users/ramdau/Documents/deps/gstreamer-1.0-android-universal-1.22.8"
)

set(GSTREAMER_ROOT_ABI "${GSTREAMER_ROOT}/${GST_ABI}")

include_directories(
    ${GSTREAMER_ROOT_ABI}/include/gstreamer-1.0
    ${GSTREAMER_ROOT_ABI}/include/glib-2.0
    ${GSTREAMER_ROOT_ABI}/lib/glib-2.0/include
)

set(
    GST_LIBS
        gstreamer-1.0
        gmodule-2.0
        gobject-2.0
        glib-2.0
        iconv
        intl
        ffi
        pcre2-8
)

set(
    GST_PLUGINS_CORE_LIBS
        gstaudioresample
        gstaudiotestsrc
        gstaudioconvert
        gstvideotestsrc
)

set(
    GST_PLUGINS_BASE
        gstcoreelements
        gsttypefindfunctions
        gstautodetect
        gstallocators-1.0
        orc-test-0.4
        gstapp-1.0
        gstaudio-1.0
        gstfft-1.0
        gstpbutils-1.0
        gstriff-1.0
        gstrtp-1.0
        gstrtsp-1.0
        gstsdp-1.0
        gsttag-1.0
        gstvideo-1.0
        gstgl-1.0
        orc-0.4
        gstaudio-1.0
        gstbase-1.0
)

# Link against zlib
find_library(
    ZLIB_LIB
    z
)

include_directories(
    ${JNI_INCLUDE_DIRS}
    ${ANDROID_NDK}/sysroot/usr/include
    ${PROJECT_SOURCE_DIR}/..
    ${PROJECT_SOURCE_DIR}
    ${GST_INCLUDE_DIRS}
)

add_library(
    ${PROJECT_NAME} SHARED
    ...(my cpp files here)
)

target_link_directories(
    ${PROJECT_NAME} PUBLIC
    ${GSTREAMER_ROOT_ABI}/lib
    ${GSTREAMER_ROOT_ABI}/lib/gstreamer-1.0
)

find_library(loglib log PATH ${ANDROID_NDK_LIB_PATH})

target_link_libraries(
    ${PROJECT_NAME} PUBLIC
    ${loglib}
    ${GST_LIBS}
    ${GST_PLUGINS_CORE_LIBS}
    ${GST_PLUGINS_BASE}
    ${ZLIB_LIB}
)

I followed the example of cmake file that I mentioned in my post above and added some additional plugins also. I link these plugins and libs to build “gstreamer_android.so” and also link all of these to my JNI lib of the actual native code. Also, following the example I have org.freedesktop.Gstreamer.kt and make initialization of gstreamer using it.

In logcat in android studio I see these logs:

2024-02-09 22:44:14.910 27144-27144 GStreamer+...IN_LOADING com.test.video_lib_playground     I  0:00:00.063972458 0xb4000077c1eecc00 ../gst/gstplugin.c:232:gst_plugin_register_static registered static plugin "videotestsrc"
2024-02-09 22:44:14.910 27144-27144 GStreamer+GST_REGISTRY  com.test.video_lib_playground     D  0:00:00.063988333 0xb4000077c1eecc00 ../gst/gstregistry.c:477:gst_registry_add_plugin:<registry0> adding plugin 0xb4000077e1e2a3f0 for filename "(NULL)"
2024-02-09 22:44:14.910 27144-27144 GStreamer+...IN_LOADING com.test.video_lib_playground     I  0:00:00.064002875 0xb4000077c1eecc00 ../gst/gstplugin.c:234:gst_plugin_register_static added static plugin "videotestsrc", result: 1

the same also for coreelements. But what is strange, before these logs I also have:

2024-02-09 22:44:14.853 27144-27144 GStreamer+GST_REGISTRY  com.test.video_lib_playground     D  0:00:00.007448583 0xb4000077c1eecc00 ../gst/gstregistry.c:1713:scan_and_update_registry scanning paths added via --gst-plugin-path
2024-02-09 22:44:14.853 27144-27144 GStreamer+GST_REGISTRY  com.test.video_lib_playground     D  0:00:00.007463792 0xb4000077c1eecc00 ../gst/gstregistry.c:1736:scan_and_update_registry GST_PLUGIN_PATH not set
2024-02-09 22:44:14.853 27144-27144 GStreamer+GST_REGISTRY  com.test.video_lib_playground     D  0:00:00.007478625 0xb4000077c1eecc00 ../gst/gstregistry.c:1748:scan_and_update_registry GST_PLUGIN_SYSTEM_PATH not set
...(some other logs)
2024-02-09 22:44:14.856 27144-27144 GStreamer+...EMENT_PADS com.test.video_lib_playground     D  0:00:00.010201000 0xb4000077c1eecc00 ../gst/gstelement.c:316:gst_element_base_class_init type GstBaseTransform : factory 0x0

Hope this helps. Please feel free to ask for more details if needed.