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

  • SEARCH
  • Home
  • 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 8298541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:48:52+00:00 2026-06-08T15:48:52+00:00

I am writing an Android app which communicates through jni with C++ (not C).

  • 0

I am writing an Android app which communicates through jni with C++ (not C). I was able to successfully pass a jstring, so the setup works, but now I want to pass a jintarray. However, the code returns an Unsatisfied Link Error on the native method, so I think I am not properly returning a jintarray.

extern "C" {

JNIEXPORT jintArray JNICALL Java_com_example_optimuse_MainActivity_generate(JNIEnv* env, jobject thiz, jintArray arr);

};

JNIEXPORT jintArray JNICALL Java_com_example_optimuse_MainActivity_generate(JNIEnv* env, jobject thiz){

    int mymusic[6];
    mymusic[0]=60;
    mymusic[1]=64;
    mymusic[2]=67;
    mymusic[3]=72;
    mymusic[4]=67;
    mymusic[5]=64;

    jintArray jmymusic = env->NewIntArray(6);

    env->SetIntArrayRegion(jmymusic, 0, 6, mymusic);

    return jmymusic;
}

And I call this in java like this:

int[] music = generate();

I think I am doing something basic wrong. Any ideas?

  • 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-06-08T15:48:54+00:00Added an answer on June 8, 2026 at 3:48 pm

    @Michael OMG! You are right. This got cut off on my screen because of resolution 😉 Must have been there from all the testing I did with importing arrays.

    Thanks a million, of course it should be

    JNIEXPORT jintArray JNICALL Java_com_example_optimuse_MainActivity_generate(JNIEnv* env, jobject thiz);
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an Android app which communicates with a PHP backend. The backend
I am writing a small app in which android device tries to send a
I am writing an android app. I want to pass some data across the
I'm writing android app, which drawing 4 graphs in 1 plot. Graph data is
I am writing an Android app, part of which will be a survey involving
I'm writing an Android app. I have a main method, which creates and runs
I'm writing an Android app which will be making use of the cloud-2-device messaging
I'm writing an android App which is basically finished and functions well on a
I am writing an Android app which submits a username and password to a
I have a question about maps API key. I'm writing an Android app which

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.