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

2019-01-06 19:10发布

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.

22条回答
萌系小妹纸
2楼-- · 2019-01-06 19:20

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.

查看更多
趁早两清
3楼-- · 2019-01-06 19:22

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 !

查看更多
Explosion°爆炸
4楼-- · 2019-01-06 19:25

In build.gradle, the line:

 apply plugin: 'android-library'

needs changed to:

 apply plugin: 'com.android.application'
查看更多
够拽才男人
5楼-- · 2019-01-06 19:25

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
查看更多
Fickle 薄情
6楼-- · 2019-01-06 19:26

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.

查看更多
该账号已被封号
7楼-- · 2019-01-06 19:27

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.

查看更多
登录 后发表回答