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 8610545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:09:29+00:00 2026-06-12T04:09:29+00:00

I have a little project with cocos2d-x libraries. I’m trying to use C++ to

  • 0

I have a little project with cocos2d-x libraries. I’m trying to use C++ to call a Java function but i get a signal 11 exception at line:

// Get Status
status = jvm->GetEnv((void **) &env, JNI_VERSION_1_6);

But i don’t know why this is happening.

In my Java class Getsocial.java exist this function:

private void tweet()
    {
        String score = "123";
        String tweetUrl = "https://twitter.com/intent/tweet?text=Hello ! I have just got " + score + " points in mygame for Android !!!!";
        Uri uri = Uri.parse(tweetUrl);
        startActivity(new Intent(Intent.ACTION_VIEW, uri));
    }

This function launch navigator to post a tweet. Called from Java works fine.

In my C++ InterfaceJNI.h I have:

#ifndef __INTERFACE_JNI_H__
#define __INTERFACE_JNI_H__

#include "cocos2d.h"

class InterfaceJNI
{
public:
    static void postMessageToFB();
    static void postMessageToTweet();

protected:

};

#endif // __INTERFACE_JNI_H__

And in InterfaceJNI.cpp:

#include "InterfaceJNI.h"
#include "platform/android/jni/JniHelper.h"
#include  jni.h >
#include  android/log.h >

using namespace cocos2d;

void InterfaceJNI::postMessageToTweet()
{
    int status;
    JNIEnv *env;
    JavaVM *jvm;
    jmethodID mid;
    jclass mClass;
    bool isAttached = false;

    CCLog("Static postMessageToTweet");

    // Get Status
    status = jvm->GetEnv((void **) &env, JNI_VERSION_1_6);

    CCLog("Status: %d", status);

    if(status AttachCurrentThread(&env, NULL);
        CCLog("Status 2: %d", status);
        if(status GetStaticMethodID(mClass, "tweet", "()V");
    CCLog("mID: %d", mid);

    if (mid!=0)
        env->CallStaticVoidMethod(mClass, mid);
            //-----------------------------------------------------------
    CCLog("Finish");
    if(isAttached)
        jvm->DetachCurrentThread();

    return;
}

This interface is called from a part of the code using:

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    InterfaceJNI::postMessageToTweet();
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    ObjCCalls::trySendATweet();
#endif

What is happening to return a null pointer on jvm->GetEnv((void **) &env, JNI_VERSION_1_6); ?

  • 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-12T04:09:31+00:00Added an answer on June 12, 2026 at 4:09 am

    It looks like your jvm variable is null or garbage. The version of Cocos2D-x I use has a class called JniHelper with a static ::getJavaVM(); method that you might want to use.

    JavaVM* vm = JniHelper::getJavaVM();
    JNIEnv* env;
    
    vm->GetEnv((void**)&env,JNI_VERSION_1_4);  // mine uses JNI_VERSION_1_4
    

    Also, remember to “refresh” your eclipse project every time you build with NDK. You probably do already, but it’s worth checking.

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

Sidebar

Related Questions

(By the way, I don't use Interface Builder) I have a little project consisting
I have a little private Google code project. For a SCM I use Mercurial.
I have a little project in which I named two same name function in
I have a little Java project where I've set the properties of the class
I have been trying to do a little project that needs an appendable ObjectOutputStream.
I am currently working on my own little project, but I have a little
I have a little project where I'm running MVC3. I use LINQ to fetch
So working on an little project but thinking about making maps efficient. I have
I have a little side project where I allow radius search. You input a
I have created a little test project to try to resolve a problem I

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.