Crash at C++ line: CallObjectMethod(...);

Bold line below was working fine in 4.15. However, this line is crashing in 4.20:

JNIEnv* env = FAndroidApplication::GetJavaEnv();

jobject activity = FAndroidApplication::GetGameActivityThis();

jmethodID mid = env->GetMethodID(env->GetObjectClass(activity), “getSystemService”, “(Ljava/lang/String;)Ljava/lang/Object;”);

jobject wifi_manager = env->CallObjectMethod(activity, mid, env->NewStringUTF(“wifi”));

What is wrong with this line and how can I fix this?

More infos are needed, like what kind of crash ?
Are any objects null in those you show/ use here ?
do you have a stack trace that is usefull ?

Did you do modifications in ProGuard config?

try to add as much debug line as you can, like :


i’ve never used jmethodID nor jobject, but check their validity too with a log, could give more idea why it’s crashing :confused:

I didn’t change anything since 4.15.

Only useless android.bat logs and this. I found the crashing line by putting UE_LOG to each line of the code. Bold line is crashing.

This was because of missing runtime permission. You can search for the relevant permission by searching ‘permission’ in monitor bat logs. Since mandatory runtime permission to get a static device id, we had to switch to dynamic device id that may change at reinstall, proved by ‘Get Device Identifier’ node.