undefined reference to || C代码中实现Surface显示

共三处修改!!!!!!!

1.

surface.c对应的Android.mk

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
 
# our source files
#
LOCAL_SRC_FILES:= \
    surface.cpp
 
LOCAL_SHARED_LIBRARIES := \
    libskia \
    libsurfaceflinger\
    libgui\

        libutils \
    liblog
 
LOCAL_C_INCLUDES += \
    $(JNI_H_INCLUDE) \
    external/skia/src/core \
    external/skia/include/core \
    frameworks/base/include \
    frameworks/base/native/include
 
# Optional tag would mean it doesn't get installed by default
LOCAL_MODULE_TAGS := optional
 
LOCAL_PRELINK_MODULE := false
LOCAL_ARM_MODE := arm
 
LOCAL_MODULE:= libjnivideo
 
include $(BUILD_SHARED_LIBRARY)



+++++

2.

int AndroidSurface_updateSurface(bool autoscale) {
    if(surface == NULL) {
        return ANDROID_SURFACE_RESULT_JNI_EXCEPTION;
    }
    if (!surface->isValid()) { //Surface::isValid()
        return ANDROID_SURFACE_RESULT_NOT_VALID;
    }

+++++

3.

static
Surface* getNativeSurface(JNIEnv* env, jobject jsurface) {
    jclass clazz = env->FindClass("android/view/Surface");
    jfieldID field_surface = env->GetFieldID(clazz, ANDROID_VIEW_SURFACE_JNI_ID, "I");//"mSurface"
    if(field_surface == NULL) {
        return NULL;
    }
    return (Surface *) env->GetIntField(jsurface, field_surface);
}

因为 android2.2以上的版本,android.view.Surface里面没有“mSurface"了,而是用了一个常量 ANDROID_VIEW_SURFACE_JNI_ID, 区分下版本就行了。



++++++++整体参考框架++++


you must copy libjnivideo.so and libjniaudio.so into lib/armeabi of your project for eclipse, which pack them into apk. If you run this project on not froyo OS you will have errors because some libraries don't be there or have other name and dalvik can't find them

I tried several times and passed finally. Here is my configuration changed for elair: from the eclair source, copy your native directory to frameworks/base/, modify the file of native/video/jni/Android.mk to add libui to LOCAL_SHARED_LIBRARIES list and replace libsurfaceflinger_client with libsurfaceflinger, modify surface.cpp to replace #include with #include , add libjniaudio.so and libjnivideo.so to the end of myandroid/build/core/prelink-linux-arm.map, then I get the libjniaudio.so and libjnivideo.so in out/target/product/generic/obj/lib for eclair. I try them in my emulator, the result is exactly beyond my imagination. It will be better if your project can fit any android version. Anyway, Thank you for your porting. If possible, I will send the three .s

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值