Application crash on conversion JString to jstring

Hi ,
Some times the application is getting crashed because of conversion of JString to jstring using "env->NewStringUTF"
as it is giving ArrayIndexOutofbound Exception,

please help

Comments

  • Kaiserludi
    Kaiserludi admin
    edited May 2016
    Hi @Harish_Kagale.

    Could you please provide some example code for that conversion?
  • Harish_Kagale
    edited May 2016
    Hi Kaiserludi

    void AndroidNetworkLogic::recieveData(const ExitGames::Common::JString& str)
    {
    jstring jstr = mEnv->NewStringUTF(str.UTF8Representation().cstr());
    mEnv->CallVoidMethod(mObj, mRecievemethod, jstr);
    mEnv->DeleteLocalRef(jstr);
    }

    this is the code that iam trying
  • Hi @Harish_Kagale.

    OK. That code looks fine to me.
    Have yout tried loging the return value of str.UTF8Representation().cstr() before passing it to NewStringUTF, so that you coudl inspect it in the log in case of a crash? That way we coudl fine out for whch stirngs this is happening for you and try to reproduce it here.

    Which SDK version are you using? If you are still below 4.0.5.0, then an update to the latest version may help, as older versions had some known issues with some Asian characters that may cause something like this.
  • Harish_Kagale
    edited May 2016
    HI,
    No i'm not logging the return value of str.UTF8Representation().cstr() , i'll try and let you know


    I'm using Photon-AndroidNDK-Sdk_v4-1-2-0