Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6168669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:43:38+00:00 2026-05-23T22:43:38+00:00

For an Android application, I have implemented an external function in C, which I

  • 0

For an Android application, I have implemented an external function in C, which I would like to use in two separate classes.

In the first class (my main Activity UI), I call the appropriate loadLibrary:

System.loadLibrary(...);

In the same class, I define the function as native:

public native int dissectPacket(byte[] header, byte[] data, int encap);

After doing this, I can call the native function with no problem in the first class. I do not get any unsatisfied link error.

Now, I want to use this function in another class. I figure I do not need to load the library again. In the second class, at the bottom, I also define:

public native int dissectPacket(byte[] header, byte[] data, int encap);

However, when I try to use the native function in the second class, I get:

07-22 23:13:13.083: ERROR/AndroidRuntime(6737): Caused by: java.lang.UnsatisfiedLinkError: dissectPacket

What is the proper way to use the function in both classes? If I do not redefine the function as native in the second class (called Packet), I get the error:

The method dissectPacket(byte[], byte[], int) is undefined for the type Packet

BTW, I do NOT want to use: class1.dissectPacket(…); I am trying to avoid passing the class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:43:38+00:00Added an answer on May 23, 2026 at 10:43 pm

    You defined actually two separate functions. One for the first class and another one for the second. They will need two separate JNI stubs. You, probably, only have stub and implementation for the first one.

    JNI and Java, in general, always refer to methods of the specific class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a simple Android application that I now would like to test
I have an Android application which retrieves from a external server, a name and
I am developing one android application in which i have implemented the 10 ads
I would like to handle screen orientation in a sample application.I have implemented code
I have two threads in an Android application, one is the view thread, and
I have an Android application that I've been working on, and it's implemented using
I am pretty far into my first Android application, and I have the sneaking
I am developing an android game application,I have implemented all the screens.Now i want
I have implemented a ListView in my Android application. I bind to this ListView
In my Android application I have created an SVG image converter class. It parses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.