本文翻译自:Error type 3 Error: Activity class {} does not exist

I have an IntelliJ Android project, that I successfully imported to Android Studio 0.4.0. 我有一个IntelliJ Android项目,该项目已成功导入到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: 当我单击与Gradle文件同步项目时 ,输出:

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

Run settings: 运行设置:


#1楼

参考:https://stackoom.com/question/1Pl10/错误类型-错误-活动类-不存在


#2楼

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 删除Build目录
  3. Restarted Android Studio 重新启动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) (可选)(转到android上的文件菜单,单击“无效的缓存/重新启动...”,卸载手机上的应用程序,然后重试)

And everything worked fine! 而且一切正常!
I think the key is to restart your IDE . 我认为关键是重新启动IDE 。

Hope this helps you or anyone else! 希望这对您或其他任何人有帮助!

Edit 1: 编辑1:
If the above steps don't work for you, then deleting Gradle cache seems to be a solution, as pointed out by @Yasitha. 如果上述步骤对您不起作用,则@Yasitha指出,删除Gradle缓存似乎是一种解决方案。

Edit 2 编辑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. 只需在终端中键入adb uninstall <package>即可从设备中完全删除应用程序。

Edit 3 编辑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. 如Abhishek的答案中所述 ,如果您的设备上设置了多个用户,则还应尝试从设备中删除该应用程序。
Simply go to Mobile Settings > Apps > [Your App] > More > Uninstall App for All Users 只需转到Mobile Settings > Apps > [Your App] > More > Uninstall App for All Users

UPDATE for Android Studio 2.1 and up Android Studio 2.1及更高版本的更新

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). 在运行Android Studio 2.1及更高版本时,如果您在首选项中启用了即时运行选项(默认情况下处于启用状态),也会遇到此问题。

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. 要禁用此选项,请转到Android Studio顶部菜单中的Preferences选项Preferences选项,然后查找“ Instant Run以便您可以取消选中该屏幕上的第一个复选框。

Anyway that fixed it for me. 无论如何,它为我解决了。 Originally pointed out by user @yusufonder. 最初由用户@yusufonder指出。 I discovered this was the issue since gradle install still worked. 我发现这是问题,因为gradle安装仍然有效。


#3楼

Try changing the name of the Activity in your AndroidManifest.xml file. 尝试在AndroidManifest.xml文件中更改“活动”的名称。

Right now it says: 现在它说:

<activity android:name="LandingActivity" >

Try either adding a period to the beginning of the Activity's name: 尝试在活动名称的开头添加句点 :

<activity android:name=".LandingActivity" >

Or adding the package name to the beginning of the Activity's name: 将包名称添加到活动名称的开头:

<activity android:name="com.trackingeng.LandingActivity" >

It also may be a problem that your package name has only two components separated by periods (your package name is "com.trackingeng"; a more standard package name would be "com.trackingeng.app") 您的软件包名称中只有两个由句点分隔的部分也可能是一个问题(您的软件包名称为“ com.trackingeng”;更标准的软件包名称为“ com.trackingeng.app”)


#4楼

I had the same error after renaming/refactoring. 重命名/重构后出现相同的错误。 What I did was add the applicationId property attribute to my build.gradle file, and set its value to the application package. 我所做的是将applicationId属性属性添加到我的build.gradle文件中,并将其值设置为应用程序包。

In build.gradle : build.gradle中 :

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

#5楼

This happens when you do the following 当您执行以下操作时,会发生这种情况

  • connect your device/emulator 连接您的设备/仿真器
  • run the app from Android Studio (AS) 从Android Studio(AS)运行应用
  • use/test the app and uninstall it from the device while it is still connected to your computer 使用/测试该应用,并在该设备仍连接到计算机时将其从设备上卸载
  • try to run the app again from AS 尝试从AS重新运行该应用

AS thinks you still have the app in your device. AS认为您的设备中仍然有该应用程序。

tl;dr - To resolve this, you can simply disconnect your device after uninstalling the app and reconnect it. tl; dr-要解决此问题,只需在卸载应用程序后重新连接设备并断开连接即可。


#6楼

我遇到了同样的问题,我解决了它,可以重构活动启动器,只需更改类名即可。

错误类型3错误:活动类{}不存在相关推荐

  1. Python 异常处理——处理默认错误类型以外错误

    一.处理一组异常 try: pass except (IOError, IndexError), e: print e 二.try ....except...else 当没有异常时,else语句才会被 ...

  2. php中常见的错误类型有,JavaScript中常见的错误类型有哪些?(详细介绍)

    在JavaScript中,当发生错误时会生成描述错误类型的错误对象,此错误对象包含错误类型和编号等信息,这些信息可用于后续处理等,在本篇文章中将给大家介绍常见的错误类型以及如何处理这些错误. Java ...

  3. python语法错误类型_python常见报错类型和异常处理

    更新ing 常见的报错类型和简析.异常处理.其他类型的报错(异常)类型简介.自定义异常 常见的报错类型和简析: 报错类型 报错内容 错误类型判断 错误解决方式 AttributeError 属性错误: ...

  4. HTTP 响应行 错误类型响应码

    新增网关响应(知识补充,和文章内容无关) 网关响应 网关响应指未能成功处理API请求,从而产生的错误响应. API网关提供默认的网关响应(default).如果您需要自定义响应状态码或网关响应内容,可 ...

  5. 解决无法将类型为“System.Web.UI.WebControls.HiddenField”的对象强制转换为类型的错误...

    解决无法将类型为"System.Web.UI.WebControls.HiddenField"的对象强制转换为类型的错误 2008-01-04 16:14 本文章将解决: 1.解释 ...

  6. 错误类型:“系统找不到 Microsoft.Office.Interop.Word(转)

    错误类型:"系统找不到 Microsoft.Office.Interop.Word" 编译出现错误: "Could not load file or assembly ' ...

  7. C# 尝试读取或写入受保护的内存,这通常指示其他内存已损坏。错误类型为:System.AccessViolationException。...

    C# 尝试读取或写入受保护的内存,这通常指示其他内存已损坏.解决方案 报错 dll文件应该是C++写的.封装了之后供我的C#程序调用,结果就提示了错误:尝试读取或写入受保护的内存.这通常指示其他内存已 ...

  8. iis启动默认页无法访问错误类型500的解决

    以前用过本机IIS没有问题,最近使用出现无法访问错误类型500的问题.基本上,这个情况可能发生在在第一次执行 .Net framework 2.0 ,原因不明,但底下的做法大致可以解決此问题: 1.首 ...

  9. java程序错误类型及异常处理

    本文转载至:http://www.cnblogs.com/liaoliao/ 一.程序的错误类型 在程序设计中,无论规模是大是小,错误总是难免的.程序的设计很少有能够一次完成,没有错误的(不是指Hel ...

最新文章

  1. cube sdio fatfs 初始化sd卡_SD卡读卡器检测——硬盘检测软件Hard Disk Sentinel Pro介绍
  2. 利用Python自动生成暴力破解的字典
  3. 使用while循环输入 1 2 3 4 5 6 8 9 10
  4. 来几个FUNNY PICS,让大家笑一笑!
  5. GNU make manual 翻译( 一百六十)
  6. 深入理解计算机系统(1)--hello world程序的生命周期
  7. synchornized实现原理
  8. 保护数据库安全十七招
  9. Flutter 自定义图片按钮,按下效果及按键音效
  10. 大数据工程师简历怎么写,更受到HR青睐?
  11. Arcgis4js实现链家找房的效果
  12. java木马源码_用Java编写木马程序【附源代码下载】
  13. java技术--报警通知及实现方式
  14. 这个时代,达不到百万级以上的并发量,都不叫高并发!!!
  15. 《罗曼蒂克消亡史》影评
  16. centos7操作系统下编译安装veracrypt
  17. 小孟网站被黑客攻击,已经哭晕在厕所……
  18. 基恩士CSV点云文件转PCD文件 PYTHON版
  19. 【Linux 内核】编译 Linux 内核 ⑦ ( 安装内核模块 | 安装内核 | 重启系统 | 查看当前内核版本 )
  20. 系统接口对接:(2)

热门文章

  1. Android开发之通过Handler的post方法更新UI
  2. Flutter编译时生成代码之 code_builder
  3. 【剑指offer-Java版】30最小的K个数
  4. 第十、十一周项目三-警察和厨师(1)
  5. Android10.0 Binder通信原理(五)-Binder驱动分析
  6. Mybatis错误:Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2]
  7. Java学习笔记32
  8. Swift 与 Objective-C混编xxx-Swift.h File not found
  9. (0009) iOS 开发之友盟统计分析SDK已全面支持HTTPS的更新
  10. 编写递归下降语法分析器_面试BAT必问的JVM,今天我们来说一说它类加载器的底层原理...