Error type 3: Activity Class {…} does not exist

2019-01-06 19:35发布

问题:

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.m.e"
      android:versionCode="5"
      android:versionName="3.0">

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

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

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
    <activity
            android:name="com.m.e"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action
                    android:name="android.intent.action.MAIN"
                    />

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity
            android:name="com.m.e"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action
                    android:name="android.intent.action.first"
                   />

            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>

    .....

</application>

</manifest>

Error :

 Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.m.e/.Splash }
 Error type 3
 Error: Activity class {com.m.e/com.m.e.Splash} does not exist.

Note: .Splash does exist.

回答1:

In build.gradle, the line:

 apply plugin: 'android-library'

needs changed to:

 apply plugin: 'com.android.application'


回答2:

I had the same error after renaming/refactoring. What I did was add the applicationId property attribute to my build.gradle file, and set its value to the application package. Like this:

android{
    defaultConfig{
        applicationId "com.example.mypackage"
    }
}


回答3:

Although it's a question posted years ago, I would like to share my solution.

Open Run->Edit Configuration, check if "Deploy default APK" is chosen in the package panel. "Deploy default APK" should be chosen.

The problem occurs to me because I choose "Do not deploy anything" earlier for some reason and I forget to undo the chosen.



回答4:

adb uninstall <your package name>

This is what worked for me. Though the app didn't even appeared as installed app but the uninstall command fixed the problem. My theory: Probably some data was left uncleared after a previous uninstall which is causing the next installation to be not fully complete.



回答5:

I also faced same problem, problem is occurred when I am uninstalling the app and same time I given build.Then in the studio it is given the above error.so I tried every option, but those are not worked for me.So I checked in the settings -> apps --> selected my application and I seen the application is in disabled state, so it is not installing (giving error).I uninstalled the application and tried build then it works fine.



回答6:

I tried all of the suggestions above, but only that solved my problem;

  1. Change package name irrelevant one and sync gradle.
  2. Change package name to really you want, sync and run.


回答7:

Go to your device settings. Select App option, select that particular app from the list, On top right corner, select Menu Bar option and select Remove for all users. It worked for me.



回答8:

I got this error on Android O (Google Pixel C).I think i will get on other devices also.

I tried to install (from AndroidStudio) to any device it was fine, but not on Android O. On Android o I was getting same error (as given below).

The root cause. I have two users on that device (user1, user2). When I uninstall the app from user1 (the app is still there in user2). When I try to reinstall the app on user1 it returns the error.Same case in user2. To resolve the issue if I uninstall the app from both the users and re-install it works.

From command link if we use "adb install -r example.apk" it works, but AndroidStudio is not doing uninstall and reinstall (if you have two users in the device).

So in my case its was because of more than one user issue. All my other device (other than Android O) are single user, that is the reason, it was working on other devices, except on Pixel C (with two users). So watch out for multi user device.

No apk changes detected since last installation, skipping installation of /home/user/Project/AndroidStudioProjects/MyAddress/app/build/outputs/apk/app-debug.apk
$ adb shell am force-stop com.arris.myaddress
$ adb shell am start -n "com.example.address/com.example.address.MainActivity1" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "com.example.address/com.example.address.MainActivity1" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.address/.MainActivity1 }
Error type 3
Error: Activity class {com.example.address/com.example.address.MainActivity1} does not exist.

Error while Launching activity


回答9:

I recently just encountered this error. I fixed it by completely uninstalling the application on my device, and then re-running.

To offer some context, this was caused by using setComponentSetting()



回答10:

Yes I know there's already an accepted answer for this but its not working (or may no longer working). Currently at Android 8.0 Oreo version, there's is a chance that your app may be uninstalled on your device "But not for all user". So the next time you debug your App with your device this error happens.

Error: Activity class "class path here" does not exist
Error type 3

Heres how you fix it which absolutely works (searched for it for 2 days trust me)

  1. If you can still see your App under Settings > App > Select your app and go to option on its Toolbar and select "Uninstall For All User"

  2. If your app is not on the App list, generate/build an APK, in my case (Android Studio 3.0.1) you can go to Build > Build Apk. Install it manually on your device. Then do Step 1.

There ! Your app is all cleaned app and perfectly uninstalled. You can now debug it with development environment.

For further research : I believe Samsung Pass app has something to do with this error. Even after Uninstall. My project is still on their list.

Happy Codings Cheers !



回答11:

When you manually changed the package name, if the manifest.xml is ok, then you need to change

apply plugin: 'android'

to

apply plugin: 'com.android.application'



回答12:

Your error states that it is looking for com.codealchemist.clashmma.splash. Most Java classes start with an uppercase letter - make sure your class name matches exactly.



回答13:

I suppose you have a devices like my LG Stylus 3 Android 7.0, in which when you press and move app from desktop to the trash, app does not removed from device. See my accepted answer on the same question for details.



回答14:

Mostly it's an eclipse issue, so the normal scenarios might work with you. Clean the project and rebuild the work space, open the manifest and check if there is any error, recheck the class name mentioned in the log, clean again and again, restart eclipse , open and clean.



回答15:

I was using a library module with an example Activity that was specified in the Manifest.

taking out the example activity from the manifest in the library project worked for me.



回答16:

Renaming the activity was the fix in my case.



回答17:

I had similar issue that I couldn't find a solution after searching and trying fixes from here and there. The only thing worked for me is creating a new project, copying all the codes in the old activities and pasting them to the new created activities (similar names but different package). It worked very good. I tried before changing the package name but it didn't work. It might work for you guys.



回答18:

In my case I tried all mentioned here and they didn't fix my problem. The problem was not in Android Studio but in device instead. And after I resetted my Android device to factory settings (as described here https://support.google.com/android-one/answer/6088915?hl=en) the problem disappeared.



回答19:

Check if you are building hidden version. That’s intended behavior for hidden app.

If you want to build regular version, you need to change Build Variant in Android Studio Build > Select Build Variant, change it to regular.



回答20:

I resolved this issue by restarting my test device and restarting Android Studio.



回答21:

This is how i fixed it. go to gradle > Tasks > Install > UninstallAll



回答22:

In build.gradle,

change

apply plugin: 'android-library'

to

apply plugin: 'com.android.application'

If your build.gradle already has apply plugin: android-library then try to clean your project.