vxh.viet
7/26/2017 - 10:03 AM

How to build and import Android GPU Image Plus?

How to build and import Android GPU Image Plus?

Source: Github

Question: How to build with only cge module (No ffmpeg, opencv or faceTracker) and import to an existing Android studio project?

Answer:

Common: Maybe leaving 64bit build for now (as we dont support 64bit yet, see this), edit jni\Application.mk:

APP_ABI := armeabi armeabi-v7a x86 mips

The Window way:

Thanks to this comment, to invoke ndk-build in Window we will need to include file extension, so ndk-build.cmd.

  • Download GPUImage Plus from Github and Android NDK.

  • Open cmd and cd into the jni folder in GPUImage Plus's library module, for example:

    cd C:\Users\Viet\Desktop\android-gpuimage-plus-master\library\src\main\jni

  • Then excute the ndk-build.cmd with the full path to NDK folder (make sure the path to NDK does not contain space), for example:

    C:\Users\Viet\AppData\Local\Android\sdk\ndk-bundle\ndk-build.cmd

  • Now we can safely delete the jni folder, (or keep some of the folders that have cpp files just for reference).

  • Go into your Android Studio project -> New -> import new Module.. -> choose the library folder.

  • In NativeLibraryLoader,comment out:

    //System.loadLibrary("ffmpeg");
    //CGEFFmpegNativeLibrary.avRegisterAll();
    

The Linux way

  • Install Ubuntu 16.04 in Virtual Box (Linux Mint may have issue, didn't remmeber correctly, just use Ubuntu to be safe).

  • Enable Shared Folder for the virtual machine following this instruction, in short:

    • Installing the Guest Additions:

      • Boot the guest OS.
      • Once booted, click Devices | Insert Guest Additions CD Image.
      • When prompted, click Run.
      • Type your user password and click Authenticate.
      • Allow the installation to complete.
      • When prompted, hit the Enter key on your keyboard.
      • Add your user to the vboxsf group with this command sudo adduser your_username vboxsf
      • Log out and log in again.
    • Add Shared Folder:

      • Right click on your Ubuntu Virtual Machine -> Settings -> Shared Folder -> Add new Machine Folder.
      • Choose/ Create any folder in the host machine that you want to share.
      • Tick on Auto Mount.
      • Restart your Ubuntu Virtual Machine, the shared folder should be available now.
  • Download GPUImage Plus from Github and put the library folder in the shared folder.

  • Download NDK and extract to shared folder just for convinient.

  • Open terminal and cd into the library's jni folder. for example:

    cd /media/sf_VirtualBoxSharedFolder/library/src/main/jni.

  • Type path_to_your_NDK/ndk-build, for example

    /media/sf_VirtualBoxSharedFolder/android-ndk-r15b-linux-x86_64/android-ndk-r15b/ndk-build.

  • Now we can safely delete the jni folder, (or keep some of the folders that have cpp files just for reference)..

  • Go into your Android Studio project -> New -> import new Module.. -> choose the library folder.

  • In NativeLibraryLoader,comment out:

    //System.loadLibrary("ffmpeg");
    //CGEFFmpegNativeLibrary.avRegisterAll();