GLThread 10 java.lang.CloneNotSupportedException

Hi,

I receive this exception in Cocos2dx on Android, any idea what could be the reason for that?

FATAL EXCEPTION: GLThread 10 java.lang.CloneNotSupportedException: Class doesn’t implement Cloneable at java.lang.Object.clone(Object.java:155) at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method) at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:72) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1348) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

BR,

JB

What’s the Android version?
I think this error is caused by the reason that Renderer changes its interface.

Hi Minggo,

It happens on several versions. Do you know any way to avoid that error? Thanks!

HTC Evo 4G (2.3.5)
Samsung Galaxy Ace (2.3.4)
Samsung Galaxy Note (2.3.6)
Samsung Galaxy Mini (2.3.4)
HTC Desire HD (2.3.3)
Samsung Galaxy Y (2.3.5)
LG G2X (2.3.4)
HTC Sensation 4G (2.3.4)

As you can imagine I don’t have so many devices, I’ve used appthwack.com to test, is a free great tool if you don’t know it :slight_smile:

Cheers!

But i can run on Galaxy Note II, which use Android v4.1.1, and G10(2.3.3).
I haven’t met this problem.

you are right, we tried with 2.1.1 hello world project and worked fine.

We finally have discovered it was because of some JPG files, maybe they were too big. If we discover the details we will share it here.

Best,

JB

I had the same error and have solved it for my case, though mine said GLThread 11:

FATAL EXCEPTION: GLThread 11
java.lang.CloneNotSupportedException: Class doesn't implement Cloneable
at java.lang.Object.clone(Object.java:155) 
at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method) 
at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:72) 
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1348) 
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

and I traced my error to an invalid JNI call.

I was incorrectly pairing GetStaticMethodInfo with a non-static CallMethod function. In my specific case it was:

GetStaticMethodInfo(…)
(int)t.env~~>CallIntMethod
when it needed to be
GetStaticMethodInfo
t.env~~>CallStaticIntMethod(…)

I found a similar error with solution at:
https://groups.google.com/group/android-ndk/tree/browse_frm/thread/71ac843f9ec586c7/f308bfcc23c10645?_done=/group/android-ndk/browse_frm/thread/71ac843f9ec586c7/f308bfcc23c10645?tvc%3D1%26&tvc=1&pli=1

In my case it also was bad JNI call ;/
But no logs about crash only useless stack trace

FATAL EXCEPTION: GLThread 8
java.lang.CloneNotSupportedException: Class doesn’t implement Cloneable
at java.lang.Object.clone(Object.java:155)
at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method)
at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:72)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1348)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

My mistake was

I call static method with such call
method.env~~>CallVoidMethod ;
And it should be
method.env~~>CallStaticVoidMethod ( method.classID, method.methodID, false );

Funny on Android 4.0 > it was working fine on android < 4.0 app crash :slight_smile: Thx for tip to look in JNI

Resurrecting this. I struggled with the same error for a full day until I stumbled on this thread.

I experienced the same error, and it was due to having “public static String” method in Cocos2dxHelpder.java:

    public static String getPriceLabel()
    {
        return "Something";
    }

I was calling this with:

String ret = "";
JniMethodInfo t;
if(JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxHelper", "getPriceLabel", "()Ljava/lang/String;"))
{ 
    jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID);
    t.env->DeleteLocalRef(t.classID);
    ret = JniHelper::jstring2string(str);
    t.env->DeleteLocalRef(str);
}

This caused the:
FATAL EXCEPTION: GLThread 8
java.lang.CloneNotSupportedException: Class doesn’t implement Cloneable

To fix this, the “public static String” needs to be changed to FINAL:
“public static FINAL String”.

    public static final String getPriceLabel()
    {
        return "Something";
    }

This fixed the problem. Had to register to the site and share this… since this was annoying fix for non-pro Java guy :slight_smile:

Thanks for sharing.