0

When my app runs in Android 6.0 or below devices(Nexus 5, Galaxy 3...), it crashes at System.loadLibrary("mylib");

It works fine with Android 7.0 devices(Nexus 5x, Nexus 9). I use latest Android Studio(2.2) and NDK.

Log cat message is

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__aeabi_memcpy8" referenced by mylib.so.

Below is part of build.gradle.

compileSdkVersion 24
buildToolsVersion '24.0.2'
defaultConfig {
    applicationId "myApp"
    minSdkVersion 10
    targetSdkVersion 24 // Whatever this is, it crashes(22, 19...).
    ndk {
        moduleName "mylib"
    }
}

Below is Application.mk

APP_ABI := armeabi armeabi-v7a x86
APP_PLATFORM := android-10 // Whatever this is, it crashes.

What is the problem?

Even if I comment out all memcpy in .c files, it issues the same error message. Before I run, I clear and rebuild project.

JohnP
  • 3
  • 1
  • 3
  • Given that it's `__aeabi_memcpy8` and it works on N (24) but not on M (23) or lower, this is most likely an issue of it compiling against android-24. When using ndk-build via gradle I would expect `APP_PLATFORM` to win, but it seems neither that nor `targetSdkVersion` is being used. If you change `compileSdkVersion` to 23 does it work? Assuming that fixes it, this is a bug. If so, could you file one? http://tools.android.com/filing-bugs – Dan Albert Oct 11 '16 at 06:13
  • No. it still crashes even though I change compileSdkVersion to 23. – JohnP Oct 11 '16 at 08:05
  • Hmm. Does gradle show the verbose output for the compilation anywhere? The `--sysroot` or `-L` arguments will point into `$NDK/platforms/android-$VERSION`. – Dan Albert Oct 11 '16 at 17:21
  • I don't know how to use it. Strangely, it works with virtual devices, but not real devices. – JohnP Oct 12 '16 at 07:20
  • In my experience the emulators do not reflect reality when it comes to native code. – Dan Albert Oct 12 '16 at 20:08
  • you could post your code somewhere? looks like you are using deprecated native building system from android studio/gradle – Gerry Oct 13 '16 at 05:18

1 Answers1

0

Make sure below your ndk>platforms hava the right paltform in your Application.mk APP_PLATFORM=Android-x.

DoubleCui
  • 49
  • 1
  • 1
  • 9