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

运行设置:


当前回答

一个简单的破解方法是重命名你的包:例如MainActivity为ApplicationMainActivity

其他回答

在我的例子中,我定义了defaultConfig两次。

我不知道为什么,但要仔细检查以防出错。

我想分享一下对我有帮助的技巧。我从设备上卸载了应用程序,所有的清理/重建/Android Studio重启操作都不起作用。

由于Android Studio认为应用程序仍然安装在设备上,不部署它,你可以使用ADB强制安装:

adb install -r <your_application_from.apk>

其中-r表示重新安装应用程序,保留其数据。

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插件从设备上卸载应用[以防你在设备设置中无法找到你的应用]

ADBIdea: https://github.com/pbreault/adb-idea

ADBIdea为Android Studio和Intellij添加了以下ADB命令:

ADB卸载App ADB Kill App ADB Start App ADB重启App ADB Clear App Data ADB清除应用数据并重新启动 ADB撤销权限 ADB启动应用程序与调试器 ADB使用调试器重新启动应用程序

调用命令有两种基本方式:

通过工具->Android->ADB Idea菜单 在“查找动作”中搜索“ADB”

Mac OS X: Cmd + Shift + A Windows/Linux: Ctrl + Shift + A

在Android机器中删除应用程序。

这对我很有用。