crittercism / crittercism-unity-android

Crittercism Plugin for Unity Crash Reporting
Other
26 stars 11 forks source link

Getting NoSuchMethodError in CrittercismAndroid.SetValue #8

Open hitorijanai opened 9 years ago

hitorijanai commented 9 years ago

http://community.crittercism.com/questions/1028/getting-nosuchmethoderror-in-crittercismandroidset.html

I'm getting this error when calling SetValue

hitorijanai commented 9 years ago

Sorry it seems the fault is mine.

I didn't set Script Execution Order of CrittercismInit to higher level.

dshirley commented 9 years ago

Anything we could fix documentation-wise to help prevent the issue you ran into? Thanks!

hitorijanai commented 9 years ago

After reviewing the problem, it turned out it was indeed SetValue that causes the exception. Script Execution Order only matters if I do something with crittercism on Awake(), before crittercism get initialised. Please look into this matter

hitorijanai commented 9 years ago

@dshirley please help :tired_face:

http://imgur.com/8AsWk5g

AndroidJavaException: java.lang.NoSuchMethodError: no method with name='put' signature='(Ljava/lang/String;Ljava/lang/String;)V' in class Lorg/json/JSONObject;
1   
at UnityEngine.AndroidJNISafe.CheckException(Unknown Source)
2   
at UnityEngine.AndroidJNISafe.GetMethodID(Unknown Source)
3   
at UnityEngine._AndroidJNIHelper.GetMethodID(Unknown Source)
4   
at UnityEngine.AndroidJNIHelper.GetMethodID(Unknown Source)
5   
at UnityEngine._AndroidJNIHelper.GetMethodID(Unknown Source)
6   
at UnityEngine.AndroidJNIHelper.GetMethodID(Unknown Source)
7   
at UnityEngine.AndroidJavaObject._Call(Unknown Source)
8   
at UnityEngine.AndroidJavaObject.Call(Unknown Source)
9   
at CrittercismAndroid.SetValue(Unknown Source)
10  
at CrittercismWrapper.SetValue(Unknown Source)
dshirley commented 9 years ago

@hitorijanai I don't have spare cycles to fix this right now. It looks like the SetValue function is missing an initialization check:

            if (!isInitialized) {
                    return;
            }

Feel free to add it there. I"m happy to merge a pull request if you've tried it and tested it.

Alternatively you could use Crittercism.setMetadata(String[], String[]). It's a more cumbersome interface but I think it would help you work around the issue.