错误类型 3 错误:Activity 类 {} 不存在 [英] Error type 3 Error: Activity class {} does not exist

查看:26
本文介绍了错误类型 3 错误:Activity 类 {} 不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 IntelliJ Android 项目,已成功导入到 Android Studio 0.4.0.如果我不更改清单中的任何内容,它就可以完美运行.但是,当我想更改启动器活动并运行时,它失败并显示以下错误:

启动应用程序:com.trackingeng/LandingActivity.设备外壳命令:am start -D -n "com.trackingeng/LandingActivity"-a android.intent.action.MAIN -c android.intent.category.LAUNCHER开始:意图{act=android.intent.action.MAINcat=[android.intent.category.LAUNCHER] cmp=com.trackingeng/LandingActivity }错误类型 3错误:活动类 {com.trackingeng/LandingActivity} 不存在.

当我点击将项目与 Gradle 文件同步时,它输出:

项目同步项目TrackingEng"不是基于 Gradle 的项目

运行设置:

解决方案

我在重构后遇到了类似的问题.
这是我为解决此问题所做的工作:

  1. 清理项目
  2. 删除了Build目录
  3. 重新启动 Android Studio
  4. 重建项目
  5. 运行
  6. 可选(转到 Android 上的文件菜单,单击使缓存无效/重新启动...",卸载手机上的应用程序,然后重试)

一切正常!
我认为关键是重启你的 IDE.

希望这对您或其他任何人有帮助!

编辑 1:
如果上述步骤对您不起作用,那么正如@Yasitha 所指出的那样,删除 Gradle 缓存似乎是一个解决方案.

编辑 2
正如以下评论中的几个用户所建议的那样,有时可以通过从您的设备中完全删除并重新安装该应用程序来解决该问题.
只需在终端中输入 adb uninstall 即可从设备中完全删除应用程序.

编辑 3

无论如何,它为我修好了.最初由用户@yusufonder 指出.我发现这是问题所在,因为 gradle install 仍然有效.

I have an IntelliJ Android project, that I successfully imported to Android Studio 0.4.0. It works perfectly if I don't change anything in manifest. However, when I want to change the launcher activity and run, it fails with this error:

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.

When I click Sync Project with Gradle files, it outputs:

Project Sync
The project 'TrackingEng' is not a Gradle-based project

Run settings:

解决方案

I faced a similar problem after refactoring.
This is what i did to resolve this issue:

  1. Cleaned the Project
  2. Deleted the Build directory
  3. Restarted Android Studio
  4. Rebuild the Project
  5. Run
  6. Optionally (Go to the files menu on android, click on "Invalidate Caches / Restart..." uninstall the app on your phone and try again)

And everything worked fine!
I think the key is to restart your IDE.

Hope this helps you or anyone else!

Edit 1:
If the above steps don't work for you, then deleting Gradle cache seems to be a solution, as pointed out by @Yasitha.

Edit 2
As suggested by a couple of users in the comments below, sometimes the issue can be resolved by completely removing and reinstalling the app from your device.
Simply type adb uninstall <package> in terminal to completely remove app from the device.

Edit 3
As mentioned in Abhishek's Answer, one should also try deleting the app from your device in case multiple users are set up on your device.
Simply go to Mobile Settings > Apps > [Your App] > More > Uninstall App for All Users

Edit 4
As mentioned by Yassin Ajdi, executing the uninstallAll Gradle task can also fix the issue.
You can go to Gradle > Tasks > Install > uninstallAll to get the job done.

UPDATE for Android Studio 2.1 and up

When running Android Studio 2.1 and up you can also encounter this issue when you have the instant run option enabled in your preferences (is enabled by default).

To disable this option go to the Preferences option in the Android Studio top menu and look for Instant Run so you can uncheck the first checkbox on that screen.

Anyway that fixed it for me. Originally pointed out by user @yusufonder. I discovered this was the issue since gradle install still worked.

这篇关于错误类型 3 错误:Activity 类 {} 不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆