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

运行设置:


当前回答

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

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

其他回答

除了第一个upvotes评论提供的情况外,还有一种情况会导致这个错误:输出的apk文件不能被Android Studio替换,你可以手动删除它并重新构建,它应该可以工作。

如果没有修改输出路径,默认的apk输出路径为{你的项目路径}/app/build/outputs/apk/debug/app-debug.apk

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.

我只是简单地解决(不要删除构建文件夹):

删除*.apk中的所有文件 “\ yourapp \ app \ \中间体\ split-apk \调试\片” 运行应用程序比较弹出消息“应用程序安装 “是否要卸载现有应用程序?”单击 好吧 重新构建项目 再次运行项目

遵循以下步骤 去 移动设置>应用>你的应用>更多>点击卸载所有用户的应用。

原因:因为你的手机有多个用户,而你只卸载了一个应用程序。

有时候,重命名项目的根目录就会发生这种情况,只需要删除项目的。idea文件夹,然后用Android Studio重新打开它。