0

I am not experienced with integrating native libraries into projects, and can't find the reason why I am getting the following error (given below)

JniJsEngine.cpp and other cpp files are present in the jni folder.

(first few lines of the errors are given)

Error:Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':libadblockplus-
android:externalNativeBuildRelease'.
> Build command failed.
Error while executing process C:\androiddev\android-ndk-r15b\ndk-build.cmd 
with arguments {NDK_PROJECT_PATH=null 
APP_BUILD_SCRIPT=C:\abcd\libadblockplus-android\jni\Android.mk 
NDK_APPLICATION_MK=C:\abcd\libadblockplus-android\jni\Application.mk 
APP_ABI=x86 NDK_ALL_ABIS=x86 NDK_DEBUG=0 APP_PLATFORM=android-9 
NDK_OUT=C:/abcd/libadblockplus-android/build/intermediates/ndkBuild/release/obj 
NDK_LIBS_OUT=C:\abcd\libadblockplus-
android\build\intermediates\ndkBuild\release\lib 
C:/abcd/libadblockplus-
android/build/intermediates/ndkBuild/release/obj/local/x86/libadblockplus-
jni.so}
Android NDK: android-9 is unsupported. Using minimum supported version 
android-14.    
[x86] SharedLibrary  : libadblockplus-jni.so
C:/abcd/libadblockplus-android/jni/JniJsEngine.cpp:222: error: 
undefined reference to 
'AdblockPlus::JsEngine::NewValue(std::__ndk1::basic_string<char, 
std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
C:/abcd/libadblockplus-android/jni/JniJsEngine.cpp:186: error: 
undefined reference 'AdblockPlus::JsEngine::SetWebRequest(std::__ndk1::shared_ptr<AdblockPlus::WebR
equest>)'
C:/abcd/libadblockplus-android/jni/JniJsEngine.cpp:90: error: undefined 
reference to 
'AdblockPlus::JsEngine::Evaluate(std::__ndk1::basic_string<char, 
std::__ndk1::char_traits<char>, 
std::__ndk1::allocator<char> > const&, std::__ndk1::basic_string<char, 
std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
...
...
...
halfer
  • 19,824
  • 17
  • 99
  • 186
burakk
  • 1,231
  • 2
  • 22
  • 45
  • Most likely, your **Android.mk** for module **adblockplus-jni** does not link a static library which contains the **JsEngine** class. If you post your project structure and the **Android.mk**, it will be easier to help you. – Alex Cohn Jul 02 '17 at 15:31

1 Answers1

0

The first error - NDK_PROJECT_PATH=null - tells you your gradle cannot find the root of your project, so it cannot compile properly. You need to set the root - and it depends on the method you are using to build NDK (NDK experimental plugin or the newer ndk-build builtin support).

Most likely, you need to set jni.srcDirs in your gradle file. You can look here: Can't build project with android-ndk and Android Studio

yakobom
  • 2,681
  • 1
  • 25
  • 33
  • `NDK_PROJECT_PATH=null` is not an error; this is how the gradle plugin launches **ndk-build** these days. – Alex Cohn Jul 02 '17 at 15:28