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

**URL:** <https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773>\
**Category:** Mobile\
**Tags:** unreal-engine, crash, Android, java, CPP, question\
**Created:** [September 30, 2018, 2:23pm UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773 "2018-09-30T14:23:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_089a4978](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_089a4978](https://forums.unrealengine.com/u/anonymous_user_089a4978)\
**Post date:** [September 30, 2018, 2:23pm UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773/1 "2018-09-30T14:23:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [October 1, 2018, 11:49am UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773/2 "2018-10-01T11:49:38Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [October 1, 2018, 12:16pm UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773/3 "2018-10-01T12:16:17Z")

</div>

Did you do modifications in ProGuard config?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_089a4978](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_089a4978](https://forums.unrealengine.com/u/anonymous_user_089a4978)\
**Post date:** [October 9, 2018, 1:07pm UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773/4 "2018-10-09T13:07:11Z")

</div>

I didn’t change anything since 4.15.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_089a4978](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_089a4978](https://forums.unrealengine.com/u/anonymous_user_089a4978)\
**Post date:** [October 9, 2018, 1:07pm UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773/5 "2018-10-09T13:07:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [October 9, 2018, 1:23pm UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773/6 "2018-10-09T13:23:04Z")

</div>

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

```
if(!env)
    UE_LOG("envNULL");

```

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_089a4978](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_089a4978](https://forums.unrealengine.com/u/anonymous_user_089a4978)\
**Post date:** [January 4, 2019, 5:18am UTC](https://forums.unrealengine.com/t/crash-at-c-line-callobjectmethod/434773/7 "2019-01-04T05:18:05Z")

</div>

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.
