Calling java function from AppDeligate crashes the app

When I’m trying to call a java function from AppDeligate through JNI before appFinishLaunch, it crashes. But when I call the same function after the app has finished launching it works. It was working perfectly fine in cocosd-x 3.4 but now that I have migrated to cocos2d-x ver 3.10 it is no more working.

Here’s the code:

C++:

string PlatformInterop::createGuid()
{
	JniMethodInfo t;
	String* pStr = NULL;
	if (JniHelper::getStaticMethodInfo(t, "com/CompanyName/android/common/Utilities", "guid", "()Ljava/lang/String;"))
	{
		jstring ret = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
		pStr = String::create(JniHelper::jstring2string(ret));
		t.env->DeleteLocalRef(ret);
		t.env->DeleteLocalRef(t.classID);
	}
	const char* cpStr =  pStr->getCString();
	string guid = cpStr;
	return guid;
}	

Java:

public static String guid()
{
	UUID uuid = UUID.randomUUID();
    String randomUUIDString = uuid.toString();
	return randomUUIDString;
}