I wish to include yctung's AndroidLibSVM into my project, so i followed his instructions to import the .AAR and set the dependencies.
Install
Install is easy, you just import our AAR library into your Android project >by the following steps:
Right-click your module -> new -> module -> Import .JAR/.AAR Package -> >select our Release/androidlibsvm-release.aar
After this, you should add the app dependency by:
Right-click your app module -> open module setting -> clieck your app -> >dependencies -> + -> module dependency -> androidlibsvm
Now I could import and work with his library as expected and Android Studio would compile the code and build without any errors. The app runs fine on an emulated device, however, it crashes on my physical device as soon as it tries to run the part of code referring to yctung's library with the following error:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memcpy" referenced by "/data/app/com.krautkremer.nils.mymirror-1/lib/arm/libjnilibsvm.so"
Referring to this SO-question, the error might be caused by incorrect Cmake/Gradle settings. If I get it right, Tung used ndk-build for his project, while I am building with Cmake. Therefor, his instructions on how to install his library may not be sufficient in my case. In fact, i haven't made any changes to the default CMakeLists.txt which i unterstand to be crucial for Cmake. I tried to add a few lines in the build.gradle and/or the CmakeLists file as they are commonly suggested in SO-solutions with no success, but i have to admit, i really don't understand what i am doing, even after reading the official guide. I am kind of lost here, since i hardly know the difference between ndk-build and Cmake, not to mention how to set them up correctly or if this is even necessary in this case. I'd be most grateful if someone could explain to me, how i can integrate AndroidLibSVM into my project correctly, what changes i have to make to my gradle/cmake files and how i have to set up my directories (in case this is part of the answer). All i've downloaded so far is the .aar which indeed does contain a few .so files but i don't understand where to put them.
Now, this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.krautkremer.nils.mymirror"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
arguments "-DANDROID_PLATFORM=android-23"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
//exclude 'META-INF/proguard/androidx-annotations.pro'
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.media:media:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ml-vision:18.0.2'
implementation 'com.google.firebase:firebase-ml-common:16.1.6'
implementation 'com.google.firebase:firebase-ml-vision-face-model:17.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1-alpha01'
implementation project(':androidlibsvm-release')
}
apply plugin: 'com.google.gms.google-services'
and this is my CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
add_library(
native-lib
SHARED
src/main/cpp/native-lib.cpp)
find_library(
log-lib
log)
target_link_libraries(
native-lib
${log-lib})
This is my directory structure.
Thank you in advance. If you need more to help me, i'd be happy to help you help me;)