1

I'm trying to use AndroidJniBitmapOperations library. But I'm a Junior Dev, with no knowledge in the NDK, JNI world.

I succeed to resolve a few errors like 'UnsatisfiedLinkError', but Now I'm getting a new one when I trying to build:

error: undefined reference to 'AndroidBitmap_unlockPixels'

Also I get a few errors inside the CPP file:

1."Incorrect type for parameter 'prarmeterName', which should have type 'jint'.

2."Add extern 'C'"

But I don't sure if the last 2 are important.

Help me to update this library, because its important and talked in SO several times, like: here.

The link for the library it self: https://github.com/AndroidDeveloperLB/AndroidJniBitmapOperations

All what I have done until now is: https://github.com/LiorA1/MyRevApp

LiorA
  • 53
  • 1
  • 12
  • Thank you for providing all the necessary information in the question. It might seem obvious to do so, but this is by a pretty wide margin one of the best questions I've seen asked here in quite some time. Thanks for putting in the effort! – Dan Albert May 14 '20 at 21:44
  • to be honest I was afraid that it will be deleted.. – LiorA May 15 '20 at 11:45

1 Answers1

5

You need to link the library that provides that API. In https://github.com/LiorA1/MyRevApp/blob/master/app/src/main/cpp/CMakeLists.txt, copy the code that you have for the logging library like so:

find_library(log-lib log)
find_library(jnigraphics-lib jnigraphics)
target_link_libraries(JniBitmapOperationsLibrary ${log-lib} ${jnigraphics-lib})

Although I think the template code is actually overly complicated here and you can simplify to just:

target_link_libraries(JniBitmapOperationsLibrary -llog -ljnigraphics)

Untested though.

As for how you can figure out which library you need to use for each Android API, I find the easiest way is to search for it on cs.android.com. For this one, I searched for AndroidBitmap_unlockPixels file:.*\.map\.txt (every NDK API is enumerated in a *.map.txt file). You can also use this page, but the code search is authoritative and makes it easier to look up an individual function rather than just "bitmap", in this case.

Dan Albert
  • 10,079
  • 2
  • 36
  • 79