Error type 3 - Error: Activity class does not exist

2.5k Views Asked by At

I know it's a duplicated question but any solution I tried not resolved the problem. The real question is there's a way to launch the app when the activity alias is enabled? I mean, my app has a feature to change the icon launcher for certain users and I want to build the app and launch it when the icon has changed, so the activity alias is enabled.

here's the error:

Error while executing: am start -n "SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=SplashScreenActivity }
Error type 3
Error: Activity class {SplashScreenActivity} does not exist.
Error while Launching activity
Failed to launch an application on all devices

Here's my manifest:

    <activity
        android:name="SplashScreenActivity"
        android:configChanges="orientation|keyboardHidden"
        android:noHistory="true"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.Launcher">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity-alias
        android:name="SplashScreenActivityAlias"
        android:icon="@mipmap/ic_launcher_prime"
        android:label="@string/app_name_app"
        android:enabled="false"
        android:targetActivity="SplashScreenActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity-alias>

I saw some resolutions that I need uninstall the app but I want to just build and launch as the app normally do.

2

There are 2 best solutions below

2
On

You haven't fully qualified the component, so it doesn't know where to find it. You need to provide the package name for your Activity, like this:

am start -n "my.package.name/.SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

Note: I have used "my.package.name" for the package. You need to replace that with your app's package name, as you have it in the manifest. Also note the "." (period, dot) character after the "/" (slash) character before SplashScreenActivity.

0
On

I have same issue when try to create a feature to change the icon launcher. Resolved the issue by invalidate cache and then refactor the activity which cause the issue. After this changes app installed successfully.