Sachin Keche
Sachin Keche

Reputation: 43

Error while excuting Android Project "Activity class does not exist."

I have created sample android project in Eclipse, but while excuting i am getting an Error: Activity class {com.example.best/com.example.best.MainActivity} does not exist.

but MainActivity class exist in project

package com.example.best;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

Following is the error message printed on the console

[2015-03-01 22:01:58 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:01:59 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:02 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:02 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:05 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:05 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:08 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:08 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:11 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:12 - best] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.best/.MainActivity }
[2015-03-01 22:02:12 - best] ActivityManager: Error type 3
[2015-03-01 22:02:12 - best] ActivityManager: Error: Activity class {com.example.best/com.example.best.MainActivity} does not exist.

Here is the content of my manifest file

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

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

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

</manifest>

what should i do for resolve this problem

Upvotes: 3

Views: 3536

Answers (3)

Oliver Hoffmann
Oliver Hoffmann

Reputation: 140

This may also happen if your target device is currently in Safe Mode which prevents it from running activities from 3rd party.

Disable Safe Mode by just rebooting your device should help in this case.

https://www.digitaltrends.com/mobile/how-to-turn-safe-mode-on-and-off-in-android/

Upvotes: 0

Atish Bundhe
Atish Bundhe

Reputation: 545

There is no error in your sample. I have tested it om my machine and it is working properly.

Please try following procedure. Project --> Clean

If it does not work then try creating new workspace.

Upvotes: 5

user4619358
user4619358

Reputation:

Whenever a new activity is added in the application, it needs to be added in the manifest file as well with a new tag. Make sure that you are doing this otherwise the new activity will not be considered.

Well i cant c any error in your sample. I created a demo project with same package name as yours, pasted exact manifest as well as MainActivity and it is working at my end.

Upvotes: 0

Related Questions