I'm trying to run DNN with the help of MNN in android studio project.
What I Do:
- I create a Native C++ project in android studio.
- I have built
libMNN.so
according to the document of MNN, and place it in the directoryapp/arm64-v8a/libMNN.so
- I have changed the
app/build.gradle
as follows
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.mymnn'
compileSdk 32
defaultConfig {
applicationId "com.example.mymnn"
minSdk 29
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
ndk {
abiFilters 'arm64-v8a'
}
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
version '3.18.1'
}
}
buildFeatures {
viewBinding true
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
- Then I can see
app/jniLibs
in Android View in android studio. It seems like I have import so file successfully. - I notice that in the MNN demo project they include MNN files by
#include <MNN/expr/Module.hpp>
rather than#include "MNN/expr/Module.hpp"
, so I thinkMNN/expr/Module.hpp
should be compiled in the so filelibMNN.so
. However, I cannot import it by#include <MNN/expr/Module.hpp>
in mysrc/main/cpp/native-lib.cpp
file.
What I Wonder
As a beginner for both C++ and android project, I want to know
- The usage of so file (does it provide some APIs that I can include in C++ header files?)
- Does
#include <MNN/expr/Module.hpp>
includesModule.hpp
from so file? If yes how can I inlcude it in my project?