我有一个IntelliJ Android项目,我成功地导入到Android Studio 0.4.0。如果我不改变manifest中的任何东西,它就能很好地工作。然而,当我想要改变启动器活动并运行时,它会失败,并出现以下错误:

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.

当我点击同步项目与Gradle文件,它输出:

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

运行设置:


当前回答

注意,如果你在设备上设置了多个配置文件,你的应用可能已经存在于其他配置文件中。

从所有配置文件中卸载应用程序为我解决了这个问题。

其他回答

我认为这个问题发生的另一个原因是,它没有完全删除设备上的所有用户。

进入“设置”->应用程序->您的应用程序->单击右上方的3个点->卸载所有用户

这对我很管用。尤其是当你改变了应用的图标或者摆弄了AndroidManifest.xml文件时。

问题发生的原因是我的模拟器。我的模拟器在SafeMood中运行。

在没有SafeMood的情况下重新启动模拟器。首先在SafeMood中自动启动,然后出现了问题。然后当我禁用SafeMood并重新启动模拟器时,它就成功了!

我通过简单地删除app ->构建文件夹,然后重建项目来解决这个问题。构建文件夹将在项目构建后自动重新创建,因此删除它没有风险。

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.

我在通过设备卸载应用程序时会遇到这个问题(即将应用程序拖到“卸载”选项)。但以下是正确的卸载方法:

使用。/gradlew uninstallAll命令。这将防止Error: Activity类{HomeActivity}不存在。错误。

更新:

如果你很懒,你可以使用这个任务的缩写:./gradlew uA。

或者在.bash_profile中为常见的gradle任务定义别名,这样做将节省时间和输入,并且您不必记住每个命令,也不必担心拼写错误。我建议这样做。