我有一个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

运行设置:


当前回答

请遵循以下步骤:

清理项目 删除构建目录 重新启动Android Studio 重新构建项目

其他回答

重构活动启动器并更改类名。

就我而言,这是因为我试图启动的应用程序在设备上为另一个用户安装了。进入设置->应用程序(所有应用程序)并选择应用程序。单击溢出菜单并选择“卸载所有用户”。

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

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

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

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.

当您执行以下操作时,就会发生这种情况

连接您的设备/模拟器 从Android Studio (AS)运行应用程序 使用/测试应用程序,并将其从设备上卸载 连接到您的计算机 尝试从AS重新运行应用程序

AS认为你的设备上还有应用程序。

tl;dr -要解决这个问题,你可以简单地断开你的设备卸载应用程序后,重新连接它。