[android] Error type 3 Error: Activity class {} does not exist

I have an IntelliJ Android project, that I successfully imported to Android Studio 0.4.0. It works perfectly if I don't change anything in manifest. However, when I want to change the launcher activity and run, it fails with this error:

Launching application: com.trackingeng/LandingActivity.
DEVICE SHELL COMMAND: am start -D -n "com.trackingeng/LandingActivity"  
    -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN  
    cat=[android.intent.category.LAUNCHER] cmp=com.trackingeng/LandingActivity }
Error type 3
Error: Activity class {com.trackingeng/LandingActivity} does not exist.

When I click Sync Project with Gradle files, it outputs:

Project Sync
The project 'TrackingEng' is not a Gradle-based project

Run settings: enter image description here

This question is related to android android-studio android-manifest

The answer is


Some times application install on Guest user on your mobile, So try to switch Guest and uninstall the application.

In addition, try to execute the following command to uninstall application adb uninstall package "Your package Name"


Just doing a clean build did the trick for me.

To do a clean build, do:

Build -> Clean Project

Then do a build or straight run on device.


I'm solving simply (don't delete build folder):

  1. deleting all files *.apk in "\yourapp\app\build\intermediates\split-apk\debug\slices"
  2. running the app compare a popup message "Application Installation failed" "Do you want to uninstall the existing application?" click Ok
  3. rebuild the project
  4. run again the project

For Android 9 devices : if your app is not installed at device already : 1) build apk 2) move apk to device and install it 3) return to Android Studio and press Run - it will launch app


For me, there was no space left on your device.


I face the similar Problem please follow the below steps.
it will help you:

1- Clean your Project
2- Delete your build directory
3- Restart your Android Studio
4- Rebuild the project
5- it will run successfully.

Thanks


In my case, it was because the app I was trying to launch was installed for a different user on the device. Go to Settings -> Apps (All apps) and and select the app. Click on the overflow menu and select "Uninstall for all users". This should solve the problem.


If your app has only two word package name like[com.example] then all your class must be mentioned with full path in menifest like [com.example.SplashActivity] instead of relative path like[.SplashActivity] change this and delete all your build folder and re-run app . Hope it will help. Thanks


My package name was like "barisciftci.PatternApplier". So changing it to all lowercase solved my problem, so now it looks as "barisciftci.patternapplier" and it works really fine.


I had the same issue and I solved it refactoring my activity launcher, just change the class name and it works.


I had same issue. My problem fixed when I disabled instant run for Android Studio 2.1.1


I resolve the problem by Edit Condifiguration -> Deploy-> Select default apk https://i.stack.imgur.com/8xuLG.png


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.

In build.gradle:

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

I'd like to share the trick that helped in my case. I uninstalled the application from the device and nothing of clean/rebuild/Android Studio restart operations didn't help.

Since Android Studio thinks that the application is still installed on the device and doesn't deploy it, you can force the installation using the ADB:

adb install -r <your_application_from.apk>

where -r means reinstall the app, keeping its data.


For me, on Android Studio 3.1.2 on Ubuntu 16.04, I met the same issue. This happens when my colleague changed the package name, and it is okay on his machine. Neither clean project nor rebuild project work.

I use Sync project with gradle files button on the top pannel of Android Studio and everything works well.


I had Error type 3. I managed to fix it by adding the following code below in AndroidMainfest.xml.

    <activity android:name=".GameActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

This happened to me using react-native run-android because my package name did not match my app ID. Just add --appId YOUR_APP_ID.


Be warned that if you have multiple Profiles set on the device, your app might already exist in one of the other Profiles.

Uninstalling the app from all the Profiles resolved the issue for me.


I faced this problem lately, and tried all suggestions above, and problem was not saved. Finally I changed a NDK, and problem was solved...


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.


In my case this was being caused by ndk abiFilters when compiling for arm. To fix it I had to add the following 'splits' section to app/build.gradle's android block:

splits {
    abi {
        enable true //enables the ABIs split mechanism
        reset() //reset the list of ABIs to be included to an empty string
        include "armeabi-v7a", "arm64-v8a", "armv7l"
        universalApk true
    }
}

If you have uninstalled the application manually from the device and you have multi user set up, this error could happen. The application needs to be uninstalled from all the users in the device.


This usually occurs when you uninstalling the App you are developing. Check whether you have activated the guest account, if so switch the account and uninstall the app, switch back to Admin user (You). and carry on!


This worked for me

Go to module settings -> Falvors -> Application id -> (Add your package name)


That might also happen if you have by mistake two launcher Activity in your AndroidManifest.xml like this:

    <activity android:name=".ActivityA">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <activity android:name=".ActivityB">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

Just leave the correct one LAUNCHER Activity


As others have noted, this problem can be caused by an attached device/emulator while uninstalling the app and AS connection still exists. On my end, I just delete all the build folders (under app and project dirs) in the project, and relaunch the application on the device/emulator.


Follow Steps Below Go to Mobile setting > Apps > Your App > More > Hit Uninstall app for all users.

Reason : Because you are having multiple users in your phone and you had uninstalled that app for only one.

ENJOY:


I think another reason that issue happen is that it is not fully deleted for all users on the device.

Go to Settings -> Apps - > Your Apps -> Click to the 3 dots on the top right -> Uninstall for all users

It works for me. It happen especially you change the icons of the app or messing around with the AndroidManifest.xml file.


If you create a new project from an existing project:

build.gradle

defaultConfig {
        applicationId "xxxxxxxxx" //xxxxxxxxx should be "package name (com.demo.app) from AndroidMenifest.xml" 
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "3.0.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
}

then click sync in the android studio


Besides the cases that the first upvoted comment provided, there is another case can cause this error: the output apk file cannot be replaced by Android Studio, you can manually delete it and build again, it should work.

If you did not change the output path, the default apk output path is {Your Project Path}/app/build/outputs/apk/debug/app-debug.apk


i just go to Build > Rebuild Project and my problem is solved


for me, on android 6 when i uninstalled the app it actually went to disabled instead of being removed from device.

Settings > Apps > click on your app and uninstall

this fixed it for me


a simple hack is to rename your package : eg MainActivity to ApplicationMainActivity


If you're not careful and you're trying to disable something in your app manifest make sure you don't disable the app...

<application
android:allowBackup="false"
android:enabled="true"
...

I accidentally set enabled to "false" instead of allowBackup. Wasted 2 hours searching for a solution.


I tried all the solutions above, nothing helped me. Then I read all the 'Run' Log. There I saw this line

"Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space"

My problem was, no internal free space to install the app. So, I deleted some files and app get installed successfully.


If you are getting this error while developing an instant app then go to Device Settings -> Apps and clear the instant app from device.


Sometimes this happens once you rename the project's root directory, just delete the .idea folder of your project and reopen it with Android Studio, it will works.


The App is already installed for Another user. Please try to uninstall the same app for all the user. Then try.

Or you can try after running adb command.

adb uninstall PACKAGE_NAME

where PACKAGE_NAME is the full name such as com.example.myapp


Keep package name same in manifest file and in build.gradle(Module:app).it resolved my problem.


Got to android/app/build.gradle and search for

 buildTypes {
     ....
 }

You might have something like

buildTypes {
    debug {
        ...
    }
    release {
        ...
    }
    customBuildType {
        ...
    }
}

Chose the buildType you want to start and then start the App the following

react-native run-android --variant=[buildType] --appIdSuffix '[buildType]'

So,

react-native run-android --variant=debug --appIdSuffix 'debug'

Android Studio 3.1.3, January 2019. After trying just about everything on here without success, this is the only thing that worked for me: Delete the virtual device and re-download it.


Had the same error, with a much newer version of Android Studio (version 4.1) . A fresh install of Android Studio + a fresh "basic Activity" template would run into error type 3 for hours. I am on win 10 - my problem was how to kill the gradle cache. A good answer above showed a screen snapshot from gradle, but i didn't find it in Android Studio 4.1. Also the env vars for gradle had not been set , and the commandline for gradle didn't work. So .. here is how it worked finally. I went to C:\Users\myusername\ .gradle. This has subdir "caches". I deleted everything inside. Worked ! I did close Android Studio before, restarted and then it worked nicely. Ah forgot one thing- i run the device emulator (defauöt device), i.e. no physical device yet.


Just in case anyone runs into my issue and has no luck with the other solutions... I was trying to start an activity through adb for FireTV while debugging Amazon launcher integration. However, my project had 60 different build variants (multi-platform, multi-app project) and the ApplicationId didn't match any classpath since the runtime package (and classpaths) were different from the applicationId.

I was trying to run adb shell am start -n com.myappid.example.packageone.packagetwo/com.myappid.example.packageone.packagetwo.MySplashActivity

(Of course I had tried many combinations with com.runtimepath.example since I had the added challenge of a different applicationId in my build.gradle and another at runtime)

What finally helped was this post https://stackoverflow.com/a/36255727/5970652

Which revealed a different format! com.myappid.example/com.runtimepath.example.packageone.packagetwo.MySplashActivity

So if you have a different runtime classpath try specifying with the build.gradle applicationId before the slash and the runtime classpath afterwards.

You can also get these values from BuildConfig.APPLICATION_ID and this.getLocalClassName() respectively if you want to log them in logcat.


My solution is: close the "instant run" of android studio.

"instant run" can be found with the following steps: Preferences -> Build,Execution,Deployment -> Instant Run

and then uncheck the checkbox "Enable Instant Run to hot swap...."


I got this error. What I tried to fix the error (didn't work) were:

  • Clean Project
  • Rebuild Project
  • Restart Android Studio

Solution was simple , just uninstall the app on your Emulator/Phone and hit "Run" on Android Studio.


In my case, I had defined defaultConfig two times.

I don't know why but double check it in case of a mistake.


May be helpful for someone:--

Sometimes when testing on a device, the app doesn't uninstall properly. To verify and fix this:

  1. Go to Settings.
  2. Go to Apps.
  3. Select your app. (here, you can verify that your app is not uninstalled properly).
  4. Open the overflow menu on the top right and select Uninstall for all users.
  5. Done. Try to install then launch your app again.

Try changing the name of the Activity in your AndroidManifest.xml file.

Right now it says:

<activity android:name="LandingActivity" >

Try either adding a period to the beginning of the Activity's name:

<activity android:name=".LandingActivity" >

Or adding the package name to the beginning of the Activity's name:

<activity android:name="com.trackingeng.LandingActivity" >

It also may be a problem that your package name has only two components separated by periods (your package name is "com.trackingeng"; a more standard package name would be "com.trackingeng.app")


I face the same issue and I think the solution is very simple than what I think it was just go to your manifest and change the package name than copy the same package name into your application iD in the Gradle

defaultConfig { applicationId "your package name here" } that's it, good luck


Though it's too late, but if someone face the same thing that i went through.. For me, the problem occurred due to my Emulator. My emulator was running in SafeMood. When i tried most of the solutions above, and these solutions didn’t worked for me. The thing that worked for me was restarting my Emulator without SafeMood. First it was started in SafeMood automatically and problem occurred. Then when i disable SafeMood and restart my Emulator it did the trick!


I have LG Stylus and in my test phone, application isn't remove permanently. In Settings -> Application I found debug app (which I try install and debug by AS) with adnotation turn-off. When I remove app from my phone, error disappeard.


In my case i uninstalled application from phone it after that the problem began but, the below command worked for me.

Execute below command in terminal/cmd

adb uninstall <package_name>

package_name something like com.example.applicationname Then, try to reinstall the application. It should work.


I had the same error message when I switched to guest profile in my emulator. I switched back to owner profile and it worked.


I also faced the same problem somewhere in the past. Such problems actually occurs when we do some refactoring like - renaming, moving files within the project etc. Renaming and Moving files require changes in the gradle file so whenever you rename or move some file just clean the project:

Build -> Clean Project

Cleaning the project just removes the .class files and recompiles the project. Basically, it forces a project rebuild.

Sometimes such types of errors did not cleaned on cleaning project then try to uninstall the app from the device (either it is emulator or physical one) and run the app again. Hope this will help you, it helps me 50% times.

Note:- Whenever you got any error just don't go to google, Clean the project if this not work do what you want to google.


When I got this problem I always try this solution and it works.

Instant Run disable 

Build -> Clean Project

File -> Invalidate Caches / Restart

But I found an exception this once. This solution doesn't work for me. Then I find out the problem is Emulator cash. I just do Wipe data and Cold boot now and the problem is solved.

enter image description here


This happens when you do the following

  • connect your device/emulator
  • run the app from Android Studio (AS)
  • use/test the app and uninstall it from the device while it is still connected to your computer
  • try to run the app again from AS

AS thinks you still have the app in your device.

tl;dr - To resolve this, you can simply disconnect your device after uninstalling the app and reconnect it.


In my case, I actually change the package name, and it started causing this issue.

I have tried many trick but here I am describing what actually worked for me.

  1. Delete your build folder it also includes the clean(so no need to clean it)
  2. Try to restart android studio if this doesn't work then invalidate the cache too.
  3. if it still give you error then try to wipe out the data of your emulator, hopefully this will resolve the issue,

Make sure your activity name is correct also make sure the package name is correct in manifest file.


I mistakenly added extra empty <application> tag in AndroidMenifest.xml which was causing this problem. I removed that and now everything is working fine


I had the same issue, and this is how I fixed it.

Go to Gradle > Tasks > Install > UninstallAll

enter image description here


Here's yet another answer, which I haven't seen in the list so far, as nothing else worked for me. Future searcher, if you've exhausted all options have a look at this one -

For me I had been playing with Android Work Profiles by making use of the Shelter App - I had copied my own application into the work profile.

I had to remove my app from both the regular profile as well as the work profile, and then the app would launch properly. Somehow the existing package inside the work profile was getting in the way of the IDE deploy.


If anyone is seeing this,

This fix worked for me as nothing from the above worked:

  1. Remove the installed debug APK from your phone
  2. In Android Studio, go to Build, choose Build APK(s)
  3. Put this generated APK on your phone and launch it
  4. Exit this app and try to debug your app again from Android Studio

This worked for me


Faced this problem in android studio 3.5.1 Took me a day to solve this problem,Tried everything including cleaning cache,restart and renaming package name as well. So if any of above did't work than try this.

Just go to gradle > Tasks > Install > UninstallAll

Here is the link: Error type 3: Activity Class {...} does not exist


In my case, I don't know why, the smartphone was blocking my app. To solve it I went to Configuration --> Application , found my app and pressed "Unistall". I went to configuration becouse my application was not appearing on menu.


I face this problem after rename my package...

so simplest one is go to File-> Invalidate caches/Restart ....


I use Android Studio 3.2 Beta 5, faced with the same issue

Go to

File -> Invalidate Caches / Restart...

Solved problem for me


I have faced to the same issue recently, remove the app in android machine solved my problem.


The file name of the SharedPreferences must be suffixed with the name of the current flavor to prevent the active compilation variant of a product from accessing the preferences of defined users for another active compilation with the same preference name.

Although each compilation package is different, it may be that when using flavorDimensions, access to user preferences is being crossed and get the Error type 3 while launching MainActivity

app.getSharedPreferences("${BuildConfig.FLAVOR}_shared_pref_3", Context.MODE_PRIVATE)

GL


For me it was a very specific problem, I've got a Lg g5 to test my application on, and to reset my apps data I uninstalled it on the phone, but the phone has a "nice" feature to don't uninstall apps immediatly so you might can reinstall them within one day. So the app was installed but not usable(disabled) after removing the app from the phone completely it worked.


None of the solutions above worked for me, I tried same app with different device it worked. Finally I noticed that the application is disabled.

  1. Go to setting/apps (on the phone)
  2. If it is disabled, remove it

That was the solution for my case


Issue was caused by uninstalling the app while the device was still plugged in. What happens is the device disables the app rather than removing it.

  1. Go to your app list on your device and uninstall the app from there. You will see that it is currently marked as disabled. This is why you cannot run the app because Android Studio fails to install it as it thinks it already exists.

In my case there was next reason:

I have 2 users: me and Guest. and app was installed on both of them but deleted only at first.

when I switched to Guest screen and delete app from there, app installed ok.

hope this will help someone :)


None of the above worked for me. I had a version of the app on the device that could not be uninstalled as it was corrupt somehow. I had to factory reset the device. Not too bothered cause it was a just a dev device


This happens when the app has not been uninstalled properly.

Use the below plugin of Android Studio to uninstall the app from the device [in case you were unable to find your app inside the settings of the device]

ADBIdea: https://github.com/pbreault/adb-idea

ADBIdea adds the following ADB commands to Android Studio and Intellij:

  • ADB Uninstall App
  • ADB Kill App
  • ADB Start App
  • ADB Restart App
  • ADB Clear App Data
  • ADB Clear App Data and Restart
  • ADB Revoke Permissions
  • ADB Start App With Debugger
  • ADB Restart App With Debugger

There are two basic ways to invoke a command:

Through the Tools->Android->ADB Idea menu By searching for "ADB" in "Find Actions" (osx: cmd+shift+a, windows/linux: ctrl+shift+a)


Even I had the same problem but none of the above solutions worked for me. The problem was that, I had froze the particular app which I was trying to run via Titanium Backup due to which I got the above error. I tried both in Eclipse and Android Studio.

After the realization I just unistalled the app and then ran it again.

Problem Solved :-)


After all these solve suggestions i still had not solved my this problem. And then i remembered my phone has 2 ANDROID User Interface. One of them is using in casual, another is private things of yours. When i download my projects to phone, downloads both of them. I deleted my project in casual one but had not private one. Everything works fine when i delete the private one. So If you have 2 android ui, you should delete all of them and download again.


Below command worked for me. Sometime partial uninstallation of the app also causes this.

Execute below command in terminal/cmd

adb uninstall <package_name>

Then, try to reinstall the application. It should work.


For me, the problem was that AndroidStudio thought that the app was still on the device.

To fix it:

  1. restart the adb daemon; in a terminal or command prompt, enter:

    adb kill-server
    adb start-server
    
  2. try to launch your app.

  3. if it still doesn't work, check out this answer.

make sure the platform-tools of the Android SDK is added to your system path variables!


I would face this problem when uninstalling the app via the device (i.e. dragging the app to the "Uninstall" option). But here is the proper way to uninstall:

Use the ./gradlew uninstallAll command. This will prevent the Error: Activity class {HomeActivity} does not exist. error.

Update:

If you’re lazy you can use the abbreviation for this task: ./gradlew uA.

Or define aliases for common gradle tasks in your .bash_profile, doing so will save time, typing, and you won’t have to remember every command nor worry about typos. I suggest doing this.


I solved it by simply deleting the app -> build folder and then rebuilding the project. The build folder is automatically recreated after the project is built so there's no risk in deleting it.


For me, I tried most of the answers, and didn't work. My Android Studio version is 4.0.1. I changed my git branch to the master branch, and then returned to my own branch, and it worked. This time I could run my branch. So weird I know


Check Application id in the Gradle file. I had the same issue because I accidentally changes application id while refactoring views name.


The best solution which worked for me was Gradle -> Tasks -> Install -> Uninstall All.


If you test your app on a smartphone, which has 24 hours secure app remove (like LG G6) you have to uninstall app manually in settings, because it is in bin for 24 hours after uninstalling, so Android Studio thinks that app is installed, but it is in app thrash on your smartphone. It worked for me.


I took reference from @jayeffkay's comment.

It works for me after I deleted the gradle cache files located in

/your_proj_directory/.gradle/2.10

2.10 is the gradle version used in my case.


I have a Samsung Galaxy. Searching in the settings above didn't work because it didn't show up at all in my Apps settings.

I found the application on my phone by typing the name of the app in the search field. I realized it was in the "Work"(using Mobile@Work) profile and removed it. You can find the settings for the profile by going to Settings->Work profile->Apps

I hope this helps somebody who may not find it the same way that many of the other answers stated it could be found in the settings.


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to android-manifest

Warnings Your Apk Is Using Permissions That Require A Privacy Policy: (android.permission.READ_PHONE_STATE) Android - Adding at least one Activity with an ACTION-VIEW intent-filter after Updating SDK version 23 Getting net::ERR_UNKNOWN_URL_SCHEME while calling telephone number from HTML page in Android How to change Android version and code version number? Error type 3 Error: Activity class {} does not exist Android open pdf file Adding Permissions in AndroidManifest.xml in Android Studio? Sending and Receiving SMS and MMS in Android (pre Kit Kat Android 4.4) Get Android .apk file VersionName or VersionCode WITHOUT installing apk versionCode vs versionName in Android Manifest