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

运行设置:


当前回答

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.

其他回答

在我的情况下,这是由ndk abiFilters编译手臂时引起的。 为了解决这个问题,我不得不在app/build中添加以下“分割”部分。Gradle的android block:

splits {
    abi {
        enable true //enables the ABIs split mechanism
        reset() //reset the list of ABIs to be included to an empty string
        include "armeabi-v7a", "arm64-v8a", "armv7l"
        universalApk true
    }
}

正如其他人所注意到的,这个问题可能是由卸载应用程序时附加的设备/模拟器引起的,而As连接仍然存在。在我这边,我只是删除了项目中的所有构建文件夹(在app和project dirs下),并在设备/模拟器上重新启动应用程序。

当我在模拟器中切换到客户配置文件时,我也收到了同样的错误消息。我切换回所有者配置文件,它工作了。

File ->使缓存失效/重新启动

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

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