Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tween.registerAccessor NoClassDefFoundError

i 'm a newbie for LibGDX and Android. Btw sorry for my bad English.

Here is my problem. I just want to make a splash screen with libgdx and i watched Dustin Riley 's libGDX tutorial on youtube. But my codes doesn 't work and here is LogCat about error.

05-07 11:05:19.004: E/AndroidRuntime(838): FATAL EXCEPTION: GLThread
05-07 11:05:19.004: E/AndroidRuntime(838): java.lang.NoClassDefFoundError: com.me.secondGame.tween.SpriteTween
05-07 11:05:19.004: E/AndroidRuntime(838):  at com.me.secondGame.screens.SplashScreen.show(SplashScreen.java:57)
05-07 11:05:19.004: E/AndroidRuntime(838):  at com.badlogic.gdx.Game.setScreen(Game.java:62)
05-07 11:05:19.004: E/AndroidRuntime(838):  at com.me.secondGame.secondGame.create(secondGame.java:10)
05-07 11:05:19.004: E/AndroidRuntime(838):  at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:292)
05-07 11:05:19.004: E/AndroidRuntime(838):  at com.badlogic.gdx.backends.android.surfaceview.GLSurfaceViewCupcake$GLThread.guardedRun(GLSurfaceViewCupcake.java:708)
05-07 11:05:19.004: E/AndroidRuntime(838):  at com.badlogic.gdx.backends.android.surfaceview.GLSurfaceViewCupcake$GLThread.run(GLSurfaceViewCupcake.java:646)

Firstly i wrote codes and that 's work without any problem. But i added some tween codes and now it doesn 't work.

Here is added code

Tween.registerAccessor(Sprite.class, new SpriteTween()); //MY ERROR ON HERE

manager = new TweenManager();

Tween.to(splashSprite, SpriteTween.ALPHA, 2f).target(1).ease(TweenEquations.easeInQuad).start(manager);

I guess there is a logical mistake. Because there is no error output.

And my SpriteTween codes.

package com.me.secondGame.tween;

import com.badlogic.gdx.graphics.g2d.Sprite;
import aurelienribon.tweenengine.TweenAccessor;

public class SpriteTween implements TweenAccessor<Sprite> {
    public static final int ALPHA = 1;

    @Override
    public int getValues(Sprite target, int tweenType, float[] returnValues) {
        switch (tweenType) {
        case ALPHA:
            returnValues[0] = target.getColor().a;
            return 1;
        default:
            return 0;
        }
    }

    @Override
    public void setValues(Sprite target, int tweenType, float[] newValues) {
        switch (tweenType) {
        case ALPHA:
            target.setColor(1, 1, 1, newValues[0]);
            break;
        }
    }
}

I can 't get what is problem and now my head 's gonna blow up.

Edited:

After Guian 's posts i created new project with guides said. Btw i watched tutorial again.

Thanks a lot.

like image 812
Utku Avatar asked Jun 01 '26 06:06

Utku


1 Answers

This kind of error happens if a class is found during compile time but not found at runtime.

You need to check that the Tween .jar file is properly included in your classpath and packaged into your APK.

Double check the inclusion process seen at Android Project Setup in the libGDX's google code page.

For example, the "libs" folder has to be called 'libs', not 'lib' nor anything else to be properly included in the APK. The Tween engine .jar file must be in this directory. Having the .jar file just in the Eclipse "Java Build Path" is insufficient.

More on this topic can be read at : NoClassDefFoundError in Java

like image 64
Guian Avatar answered Jun 04 '26 13:06

Guian