android - 无法使用 Android NDK 构建 gstreamer

标签 android c++ android-ndk gstreamer

我正在按照本教程构建一个 gstreamer 项目 - http://docs.gstreamer.com/display/GstSDK/Android+tutorial+1%3A+Link+against+GStreamer

我在 jni 文件夹中创建了两个名为 main.cpp 和 Android.mk 的文件。 jni 文件夹在 Android 项目中。不过,我认为无论如何位置都不重要。这些是这两个文件的内容 - 安卓.mk -

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := test
LOCAL_SRC_FILES := main.c
LOCAL_SHARED_LIBRARIES := gstreamer_android
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

ifndef GSTREAMER_SDK_ROOT
ifndef GSTREAMER_SDK_ROOT_ANDROID
$(error GSTREAMER_SDK_ROOT_ANDROID is not defined!)
endif
GSTREAMER_SDK_ROOT        := $(GSTREAMER_SDK_ROOT_ANDROID)
endif
GSTREAMER_NDK_BUILD_PATH  := $(GSTREAMER_SDK_ROOT)/share/gst-android/ndk-build/
GSTREAMER_PLUGINS         := coreelements
include $(GSTREAMER_NDK_BUILD_PATH)/gstreamer.mk

main.cpp -

#include <string.h>
#include <jni.h>
#include <android/log.h>
#include <gst/gst.h>

jstring gst_native_get_gstreamer_info (JNIEnv* env, jobject thiz) {
    char *version_utf8 = gst_version_string();
    jstring *version_jstring = (*env)->NewStringUTF(env, version_utf8);
    g_free (version_utf8);
    return version_jstring;
}

static JNINativeMethod native_methods[] = {
{ "nativeGetGStreamerInfo", "()Ljava/lang/String;", (void *)     gst_native_get_gstreamer_info}
};

jint JNI_OnLoad(JavaVM *vm, void *reserved) {
    JNIEnv *env = NULL;
    if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) {
        __android_log_print (ANDROID_LOG_ERROR, "tutorial-1", "Could not retrieve JNIEnv");
        return 0;
    }
    jclass klass = (*env)->FindClass (env, "com/gst_sdk_tutorials/tutorial_1/Tutorial1");
    (*env)->RegisterNatives (env, klass, native_methods, G_N_ELEMENTS(native_methods));
    return JNI_VERSION_1_4;
}

当我从该目录执行 ndk-build 时,出现以下错误 -

make: -n: Command not found
/bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
 /bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
/bin/sh: 0: Illegal option - 
GStreamer      : [GEN] => gst-build/gstreamer_android.c
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
/bin/sh: 1: i: not found
make: [genstatic] Error 127 (ignored)
GStreamer      : [COMPILE] => gst-build/gstreamer_android.c
gst-build/gstreamer_android.c:9:2: error: stray '@' in program
  @PLUGINS_DECLARATION@
  ^
gst-build/gstreamer_android.c:9:22: error: stray '@' in program
  @PLUGINS_DECLARATION@
                      ^
gst-build/gstreamer_android.c:12:2: error: stray '@' in program
   @G_IO_MODULES_DECLARE@
  ^
gst-build/gstreamer_android.c:9:3: error: unknown type name 'PLUGINS_DECLARATION'
  @PLUGINS_DECLARATION@
   ^
gst-build/gstreamer_android.c:12:23: error: stray '@' in program
  @G_IO_MODULES_DECLARE@
                       ^
gst-build/gstreamer_android.c:15:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'

然后……

最佳答案

Android 版 GStreamer 的最新版本与 ndk-r10e 兼容(至少它们解决了 HOST_SED 问题)。请参阅此错误以供引用:https://bugzilla.gnome.org/show_bug.cgi?id=750162

在这里您可以找到最新的预构建 GStreamer for Android 包:http://gstreamer.freedesktop.org/data/pkg/android/1.5.91/

教程中您要链接的版本真的很旧。

编辑:我可以确认这现在有效:)

enter image description here

关于android - 无法使用 Android NDK 构建 gstreamer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30844238/

相关文章:

android - APK 打包时重复文件,libpjsua2.so

java - 如何使 Android 猜谜游戏将猜测次数限制为 3 次尝试,之后将显示一条消息

c++ - 递归逃出迷宫

java - 启动示例Android NDK 'Hello JNI'应用程序时出现Gradle兼容性错误

Android:使用 android.support.v7.widget.Toolbar 的 RuntimeException 和 InflateException

java - 大字符串导致的 OutOfMemoryException

c++ - 你如何处理命令行选项和配置文件?

c++ - 构造函数体中的对象初始化

android - 共享对象、符号、C/C++ lib 链接和加载

android-ndk - android.graphics.Canvas 中使用的算法