nnstreamer / nntrainer

NNtrainer is Software Framework for Training Neural Network Models on Devices.
Apache License 2.0
144 stars 72 forks source link

Android build failed for KNN (missing libs folder?) #646

Closed Seladam closed 3 years ago

Seladam commented 3 years ago

I'm having issues with compiling the KNN project with Android Studio.

Preconditions:

Build Steps

**1. git clone https://github.com/nnstreamer/nntrainer

  1. cd nntrainer
  2. sudo apt install devscripts
  3. sudo apt install tensorflow-lite-dev
  4. meson build
  5. ninja -C build**

image

7. Download and extract Gstreamer from: https://gstreamer.freedesktop.org/data/pkg/android/1.18.0/gstreamer-1.0-android-universal-1.18.0.tar.xz 8. Download and extract Tensorflow-lite android resources from nnstreamer-android-resource repository: https://raw.githubusercontent.com/nnstreamer/nnstreamer-android-resource/master/external/tensorflow-lite-1.13.1.tar.xz 9. Set environment variables: 9.1. sudo -H gedit /etc/environment 9.2. Add variables in new lines:

ANDROID_NDK=/home/user/Android/Sdk/ndk/21.3.6528147
NNTRAINER_ROOT=/home/user/nntrainer
TENSORFLOW_ROOT=/home/user/Downloads/tensorflow-lite-1.13.1/tensorflow-lite
GSTREAMER_ROOT_ANDROID=/home/user/Downloads/gstreamer-1.0-android-universal-1.18.0

image

**9.3. Save the file 9.4. Log out and log in to refresh the environment

  1. Open the KNN project in Android Studio**

image

11. Set the NDK location in the PRoject Settings 11.1 File -> Project Structure...

image

11.2 SDK Loacation -> Android NDK location: select the installed ndk path

image

12. Make Project

Results:

image image

In the Android.mk file at line 42, there is a reference to libnntranier.so with a path which doesn't exist. LOCAL_SRC_FILES := $(NNTRAINER_ROOT)/libs/$(TARGET_ARCH_ABI)/libnntrainer.so I don't have any libs folder in the nntrainer folder after cloning and building the repo.

What build command should I use to generate the libs folder? Or where should I look for it?

Notes:

Environment:

taos-ci commented 3 years ago

:octocat: cibot: Thank you for posting issue #646. The person in charge will reply soon.

jijoongmoon commented 3 years ago

First of all, we have to apologize confusion about gstreamer releated. we should have to delete the xml and gradle file. They don't need for this application. I think you need to build nntrainer library for android first. Once you do ninja -C build, it is built for x86_64 in build directory. So you cannot use it for android. In order to build libnntrainer.so library for android you need to use ndk-build.

If you do

cd ${NNTRAINER_ROOT}/jni
ndk-build

then you will have libnntrainer.so in ${NNTRAINER_ROOT}/libs/${TARGET_ARCH_ABI}/

and then

cd ${NNTRAINER_ROOT}/Applications/KNN/jni/
ndk-build

the you will have knn_sample in ${NNTRAINER_ROOT}/Applications/KNN/libs/