user1193425
user1193425

Reputation: 299

Calling a native method from Android project

I'm creating an app that tries to inject a touch event, which requires the event time. When I call SystemClock.uptimeMillis() to get the time, there is a run time error. I think the problem arises from the fact that uptimeMillis() is a native method. The error thrown during runtime is an UnsatisfiedLinkError.

The android jar file is included in the project, allowing for compilation without any errors. I think the problem is that the java wrapper (SystemClock.java) is available in the project. However, the native method in C (from file android_os_SystemClock.cpp) cannot be found during run time. Any ideas on how to include the native methods (required by the java wrappers) when building my project?

Thanks a lot!

Upvotes: 0

Views: 734

Answers (1)

poloolop
poloolop

Reputation: 144

You can import an NDK project in to your Eclipse SDK project. On your project do a right-click and chose -> Android Tools -> Add Native Support -> Click Finish. This will pull your native project files to Eclipse. Now you have to implement the functions as given in several sample projects.

Upvotes: 3

Related Questions