Android NDK Android.mk location in Android Studio 2.3.2

Viewed 1417

When generating a new project with NDK support in Android Studio 2.3.2 you no longer get an Android.mk file auto-generated in the jni/ dir.

You now get a CMakeLists.txt in the cpp/ dir.

There is no jni/ dir any more.

If you still wish to use an Android.mk file with ndk-build rather than CMake where does the file go?

Should it be created in the cpp/ dir?

Or does it go in the app/ dir same as the CMakeLists.txt?

Do you have to delete the CMakeLists.txt file if you create an Android.mk file if you intend for Android Studio to auto-build the native shared lib rather than running ndk-build explicitly?

Update - Linking to 3rd party libs:

I've generated a bunch of libusb .so files, i.e.

  ~/projects/third-party/libusb-1.0.21/android/libs:
  total used in directory 36 available 265852464
  drwxrwxr-x 9 bph bph 4096 Jun  2 22:20 .
  drwxr-xr-x 5 bph bph 4096 Jun  2 22:20 ..
  drwxrwxr-x 2 bph bph 4096 Jun  5 14:05 arm64-v8a
  drwxrwxr-x 2 bph bph 4096 Jun  5 14:05 armeabi
  drwxrwxr-x 2 bph bph 4096 Jun  5 14:05 armeabi-v7a
  drwxrwxr-x 2 bph bph 4096 Jun  5 14:05 mips
  drwxrwxr-x 2 bph bph 4096 Jun  5 14:05 mips64
  drwxrwxr-x 2 bph bph 4096 Jun  5 14:05 x86
  drwxrwxr-x 2 bph bph 4096 Jun  5 14:05 x86_64

contents of mips64/ for example looks like:

~/projects/third-party/libusb-1.0.21/android/libs/mips64:
  total used in directory 276 available 265852464
  drwxrwxr-x 2 bph bph   4096 Jun  5 14:05 .
  drwxrwxr-x 9 bph bph   4096 Jun  2 22:20 ..
  -rwxr-xr-x 1 bph bph  14872 Jun  5 14:05 dpfp
  -rwxr-xr-x 1 bph bph  14944 Jun  5 14:05 dpfp_threaded
  -rwxr-xr-x 1 bph bph  27432 Jun  5 14:05 fxload
  -rwxr-xr-x 1 bph bph  10680 Jun  5 14:05 hotplugtest
  -rwxr-xr-x 1 bph bph 127544 Jun  5 14:05 libusb1.0.so
  -rwxr-xr-x 1 bph bph  10624 Jun  5 14:05 listdevs
  -rwxr-xr-x 1 bph bph  10712 Jun  5 14:05 sam3u_bphchmark
  -rwxr-xr-x 1 bph bph  14912 Jun  5 14:05 stress
  -rwxr-xr-x 1 bph bph  35640 Jun  5 14:05 xusb

i.e. the cross-build .so file is in there..

In CMakeLists.txt my link_directories looks like this:

link_directories( ~/projects/third-party/libusb-1.0.21/android/libs/${ANDROID_ABI}/

My target_link_libraries looks like this:

target_link_libraries( # Specifies the target library.
                       usb-1.0 )

But I'm getting linking errors:

~/Android/Sdk/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64/lib/gcc/mips64el-linux-android/4.9.x/../../../../mips64el-linux-android/bin/ld: cannot find -lusb-1.0

Its as though the link_directories isn't getting picked up, or ${ANDROID_ABI} isn't working?

The mod to the build.gradle file wouldn't have any bearing on linker errors right?

1 Answers
Related