Error type 3 Error: Activity class {} does not exi

2019-01-03 08:01发布

I have an INTELIJ(v12) android project successfully imported to AndroidStudio(v0.4.0). It works perfectly if I don't change anything in manifest. When I want to change the launcher activity and run, it outputs with the following 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

Anyone has faced this problem? Any ideas?

Run settings: enter image description here

30条回答
The star\"
2楼-- · 2019-01-03 08:38

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-03 08:40

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.

查看更多
够拽才男人
4楼-- · 2019-01-03 08:40

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.

查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-03 08:40

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

查看更多
Ridiculous、
6楼-- · 2019-01-03 08:40

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.

查看更多
【Aperson】
7楼-- · 2019-01-03 08:41

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.

查看更多
登录 后发表回答