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

运行设置:


当前回答

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

其他回答

如果你在智能手机上测试你的应用程序,它有24小时安全应用程序删除(如LG G6),你必须在设置中手动卸载应用程序,因为卸载后24小时它在bin中,所以Android Studio认为应用程序已经安装,但它在你的智能手机上的应用程序thrash中。

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.

我用……来解决这个问题 Edit configuration -> Deploy->选择“default apk” https://i.stack.imgur.com/8xuLG.png

如果你的应用只有两个字的包名,比如[com. com.]示例],那么你所有的类都必须在manifest中以完整路径提到,如[com.example]。SplashActivity]而不是类似[的相对路径。SplashActivity] 更改此并删除所有构建文件夹并重新运行应用程序。

我在重命名/重构后也出现了同样的错误。我所做的就是将applicationId属性添加到我的构建中。Gradle文件,并将其值设置为应用程序包。

在build.gradle:

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