0

I am new to android game development, i downloaded AndEngine source and other extension from GitHub, and created a new project added jar from the bin of andengine, extended my main activity with SimpleGameActivity and override the abstract methods...but when i am trying to run this project its is saying Fatal exception...BLA BLA....i am stuck here for last 3 hrs...dont knw what to do ?

Here is my code fro main activity

import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.util.FPSLogger;

import org.andengine.ui.activity.SimpleBaseGameActivity;


public class MainActivity extends  SimpleBaseGameActivity {

    // ===========================================================
    // Constants
    // ===========================================================

    protected static final int CAMERA_WIDTH = 720;
    protected static final int CAMERA_HEIGHT = 480;

    private Scene mScene;

    @Override
    public EngineOptions onCreateEngineOptions() {
        final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
        return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
    }

    @Override
    public void onCreateResources() {
    }

    @Override
    public Scene onCreateScene() {
        this.mEngine.registerUpdateHandler(new FPSLogger());

        this.mScene = new Scene();
        this.mScene.setBackground(new Background(0, 0, 0));

        return this.mScene;
    }


}

and Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="15" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
    <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

</manifest>

and Log Cat is

12-12 17:26:00.759: W/dalvikvm(20868): Unable to resolve superclass of Lcom/example/test/MainActivity; (558)
12-12 17:26:00.759: W/dalvikvm(20868): Link of class 'Lcom/example/test/MainActivity;' failed
12-12 17:26:00.759: D/AndroidRuntime(20868): Shutting down VM
12-12 17:26:00.759: W/dalvikvm(20868): threadid=1: thread exiting with uncaught exception (group=0x40018578)
12-12 17:26:00.799: E/AndroidRuntime(20868): FATAL EXCEPTION: main
12-12 17:26:00.799: E/AndroidRuntime(20868): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.test/com.example.test.MainActivity}: java.lang.ClassNotFoundException: com.example.test.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.test-1.apk]
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.os.Looper.loop(Looper.java:130)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.app.ActivityThread.main(ActivityThread.java:3687)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at java.lang.reflect.Method.invokeNative(Native Method)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at java.lang.reflect.Method.invoke(Method.java:507)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at dalvik.system.NativeStart.main(Native Method)
12-12 17:26:00.799: E/AndroidRuntime(20868): Caused by: java.lang.ClassNotFoundException: com.example.test.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.test-1.apk]
12-12 17:26:00.799: E/AndroidRuntime(20868):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-12 17:26:00.799: E/AndroidRuntime(20868):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
12-12 17:26:00.799: E/AndroidRuntime(20868):    ... 11 more

I am trying to run this in samsung Galaxy pop

i found this tutorial at http://www.youtube.com/watch?v=zVIZSKP3tR8

Finally i ot the solution and I didnt had to change the source code...

NoClassDefFoundError - Eclipse and Android

Community
  • 1
  • 1
Nipun David
  • 29
  • 1
  • 3

3 Answers3

3

Make sure that the andengine.jar is not only listed under "Java Build Path" > "Libraries" but also exported: "Java Build Path" > "Order and Export".

Or if that doesn't work out you can always link the whole AndEngine Project with yours. Just Import the AndEngine project into your Eclipse (if you haven't done it already) and the instead of copying the andengine.jar do:

  • in the AndEngine project choose "properties" > "android" and under "library" mark as "Is Library"
  • back in your project choose "properties" > "J*ava Build Path*" > "Projects" and then "add" -> you see all your projects in your workspace, choose AndEngine
  • switch to the "Order and Export" Tab and make sure the AndEngine gets exported too.
  • choose "properties" > "android" and under "library" add "AndEngine"

this should do the trick (at least it is working for me) I am sorry if I may have messed up the order of steps.

GameDroids
  • 5,338
  • 6
  • 34
  • 54
-1

Change to

this.mText = new Text(50, 40, this.mFont, "", 1000, new TextOptions(AutoWrap.LETTERS, AUTOWRAP_WIDTH, HorizontalAlign.CENTER, Text.LEADING_DEFAULT), vertexBufferObjectManager);
Hallaz
  • 109
  • 2
  • 3
  • 15
-1

your code works on my Android Studio, looks like it is good but you have to clean and rebuild the project.

Ian Holing
  • 119
  • 1
  • 3