2017-02-25 4 views
0

openCvリファレンスで自分のアンドロイドプロジェクトを作成し、プロジェクトを設定し、モジュールとしてSDKにjavaを追加し、すべてのlibs(異なるCPUタイプ)をjinLibsにコピーします!私はこの例外を得た私のプロジェクトをビルドしようとすると、私はlibdetection_based_trackerAndroid OpenCV未定義のネイティブクラスへの参照

という名前の1つのネイティブクラスを持っている:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.0" 
    defaultConfig { 
     applicationId "ir.whiteapp.maremat" 
     minSdkVersion 15 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
     externalNativeBuild { 
      cmake { 
       cppFlags "" 
      } 
     } 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    externalNativeBuild { 
     cmake { 
      path "CMakeLists.txt" 
     } 
    } 
    sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/'] } } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.0.1' 
    testCompile 'junit:junit:4.12' 
    compile project(':openCVLibrary320') 
} 

と私のCmakeList

:ここ

CMakeFiles/libdetection_based_tracker.dir/src/main/cpp/libdetection_based_tracker.cpp.o: In function `Java_ir_whiteapp_maremat_DetectionBasedTracker_nativeCreateObject': 
G:\AR\Maremat\app\src\main\cpp/libdetection_based_tracker.cpp:28: undefined reference to `DetectionBasedTracker::Parameters::Parameters()' 
G:\AR\Maremat\app\src\main\cpp/libdetection_based_tracker.cpp:31: undefined reference to `DetectionBasedTracker::DetectionBasedTracker(std::string const&, DetectionBasedTracker::Parameters const&)' 
CMakeFiles/libdetection_based_tracker.dir/src/main/cpp/libdetection_based_tracker.cpp.o: In function `Java_ir_whiteapp_maremat_DetectionBasedTracker_nativeSetFaceSize': 
G:\AR\Maremat\app\src\main\cpp/libdetection_based_tracker.cpp:64: undefined reference to `DetectionBasedTracker::getParameters()' 
G:\AR\Maremat\app\src\main\cpp/libdetection_based_tracker.cpp:66: undefined reference to `DetectionBasedTracker::setParameters(DetectionBasedTracker::Parameters const&)' 
CMakeFiles/libdetection_based_tracker.dir/src/main/cpp/libdetection_based_tracker.cpp.o: In function `cv::Mat::operator=(cv::Mat const&)': 

は私のアプリレベルのGradleファイルです

cmake_minimum_required(VERSION 3.4.1) 

include_directories(src/main/jniLibs/jni/include) 
add_library(lib_opencv SHARED IMPORTED) 
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so) 
add_library(native-lib SHARED src/main/cpp/native-lib.cpp) 
add_library(libdetection_based_tracker SHARED src/main/cpp/libdetection_based_tracker.cpp) 

find_library(# Sets the name of the path variable. 
      log-lib 

      # Specifies the name of the NDK library that 
      # you want CMake to locate. 
      log) 

target_link_libraries(# Specifies the target library. 
        native-lib 

        # Links the target library to the log library 
        # included in the NDK. 
        ${log-lib}) 

プロジェクト全体がhere jinLibs fなしile!これはNDKとOpenCVで作業する私の最初の試みですが、私の質問の一部があいまいであるかどうか私に尋ねてください!

答えて

0

thisによると、Android.mkは、次のようになります。

LOCAL_PATH := $(call my-dir) 

include $(CLEAR_VARS) 
LOCAL_MODULE := asmlibrary 

LOCAL_SRC_FILES := so/$(TARGET_ARCH_ABI)/libasmlibrary.so #must be included 
include $(PREBUILT_SHARED_LIBRARY) 

include $(CLEAR_VARS) 

#OPENCV_CAMERA_MODULES:=off 
#OPENCV_INSTALL_MODULES:=off 
#OPENCV_LIB_TYPE:=SHARED 

include /youropencv/OpenCV-2.4.6-android-sdk/sdk/native/jni/OpenCV.mk 

LOCAL_SRC_FILES := DemoFit.cpp 

LOCAL_C_INCLUDES += $(LOCAL_PATH) 
LOCAL_CFLAGS += -DOPENCV_OLDER_VISION #(if still get errors, disable OPENCV_OLDER_VISION) 

LOCAL_LDLIBS  += -llog -ldl 

LOCAL_MODULE  := jni-asmlibrary 

LOCAL_SHARED_LIBRARIES := asmlibrary 

include $(BUILD_SHARED_LIBRARY) 
+0

を私はOpenCVの3.2.0をダウンロードしますが、私のlibフォルダがlibasmlibrary.soが含まれていません!私のプロジェクトには必要なのですか? –

関連する問題