Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot be cast to android.app.Activity [closed]

Tags:

android

please help when i run my application i get these errors, im trying to make an android game

i have been trying to solve this problem and other problems for more than 3 days

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zargoun.please"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.zargoun.please.Main"
            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>

</manifest>

StackTrace

     D/AndroidRuntime(1115): Shutting down VM
     W/dalvikvm(1115): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
     E/AndroidRuntime(1115): FATAL EXCEPTION: main
     E/AndroidRuntime(1115): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.zargoun.please/com.zargoun.please.Main}: java.lang.ClassCastException: com.zargoun.please.Main cannot be cast to android.app.Activity
     E/AndroidRuntime(1115):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
     E/AndroidRuntime(1115):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
     E/AndroidRuntime(1115):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
     E/AndroidRuntime(1115):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
     E/AndroidRuntime(1115):    at android.os.Handler.dispatchMessage(Handler.java:99)
     E/AndroidRuntime(1115):    at android.os.Looper.loop(Looper.java:137)
     E/AndroidRuntime(1115):    at android.app.ActivityThread.main(ActivityThread.java:5041)
     E/AndroidRuntime(1115):    at java.lang.reflect.Method.invokeNative(Native Method)
     E/AndroidRuntime(1115):    at java.lang.reflect.Method.invoke(Method.java:511)
     E/AndroidRuntime(1115):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
     E/AndroidRuntime(1115):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
     E/AndroidRuntime(1115):    at dalvik.system.NativeStart.main(Native Method)
     E/AndroidRuntime(1115): Caused by: java.lang.ClassCastException: com.zargoun.please.Main cannot be cast to android.app.Activity
     E/AndroidRuntime(1115):    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
     E/AndroidRuntime(1115):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
     E/AndroidRuntime(1115):    ... 11 more

i get Error: The method setContentView(int) in the type Activity is not applicable for the arguments (Maing)

public class Main extends Activity {

    private Maing _game;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        _game = new Maing();

        setContentView(_game);
    }


}

this is the class maing.java it implements Screen from libgdx library

import com.badlogic.gdx.Screen;

public class Maing implements Screen{

    @Override
    public void dispose() {
        // TODO Auto-generated method stub

    }

    @Override
    public void hide() {
        // TODO Auto-generated method stub

    }

    @Override
    public void pause() {
        // TODO Auto-generated method stub

    }

    @Override
    public void render(float arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void resize(int arg0, int arg1) {
        // TODO Auto-generated method stub

    }

    @Override
    public void resume() {
        // TODO Auto-generated method stub

    }

    @Override
    public void show() {
        // TODO Auto-generated method stub

    }
like image 708
zargoun Avatar asked Feb 16 '23 07:02

zargoun


1 Answers

Your "Main" class doesn't extend Activity. That's all I can see with only your manifest and StackTrace.

like image 193
LuigiPower Avatar answered Feb 24 '23 07:02

LuigiPower