简体   繁体   English

启动Activity时出现“错误类型3错误:活动类{}不存在”,错误类型3活动类不存在“

[英]“Error type 3 Error: Activity class {} does not exist” ,Error type 3 Activity class does not exist " while launching Activity

Recently I renamed my android project package name, then when I ran the project it gave these two errors: 最近,我重命名了我的android项目包名称,然后在运行该项目时出现了以下两个错误:

Error type 3 Error: Activity class {} does not exist
Error type 3 Activity class does not exist

I checked my build.gradle and found the applicationId didn't change. 我检查了build.gradle ,发现applicationId不变。 After updating it, nothing was solved. 更新之后,什么都没有解决。 The same errors kept showing. 相同的错误不断显示。 One appears, then I do something, then the other appears...and so on. 一个出现,然后我做某事,然后另一个出现...,依此类推。

After a lot of searching, they suggested cleaning the project and deleting some folders (like .gradle and build ) and rebuilding the project after restarting Android Studio, but none of that solved my problem. 经过大量搜索后,他们建议清理项目并删除一些文件夹(例如.gradlebuild ),然后在重新启动Android Studio之后重新build项目,但是这些都没有解决我的问题。

Any suggestions? 有什么建议么?

after a long night , I found the solution. 漫长的夜晚之后,我找到了解决方案。 simply my phone storage was almost full (400mb) left . 只是我的手机存储空间几乎已满(400mb)。 I cleaned up some space , and then it worked. 我清理了一些空间,然后工作了。

Aditional thing to do if nothing solved in your case : Tools > android > Sync Project with Gradle Files. 如果您的情况没有解决,请执行其他操作:工具> android>使用Gradle文件同步项目。

yes there is a way click on compact middle pages then right click on pakage name and refactor then rename. 是的,有一种方法可以单击紧凑的中间页,然后右键单击包装名称并重构然后重命名。 hope it will solve your problem. 希望它能解决您的问题。 i posted an image, 我张贴了一张图片, 在此处输入图片说明 dont know where it gone 不知道它去了哪里

It is a easy problem which is happened when you migrate to androidX or refactoring the package name. 这是一个简单的问题,当您迁移到androidX或重构包名称时就会发生。 An easy solution is: 一个简单的解决方案是:

  1. Make a new project (same package name as the current one) 制作一个新项目(与当前项目名称相同的软件包名称)
  2. go to app\\src\\main and delete all files in main directory (for this new project) 转到app \\ src \\ main并删除主目录中的所有文件(对于该新项目)
  3. Go to app\\src\\main and copy all files in main directory (for the old project) 转到app \\ src \\ main并复制主目录中的所有文件(对于旧项目)
  4. Paste the files in app\\src\\main directory (the new project) 将文件粘贴到app \\ src \\ main目录(新项目)中
  5. Run the new project 运行新项目

The problem could be in your Manifest file. 问题可能出在您的清单文件中。 Check the AndroidManifest.xml file. 检查AndroidManifest.xml文件。

Check the presence of those intent-filters inside your Activity declaration. 检查活动声明中是否存在那些意图过滤器。 Like below. 像下面。

<activity
     android:name=".main.SplashScreenActivity"       
     android:label="@string/app_name"
     android:screenOrientation="portrait">
     <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
 </activity>

If this information is there, maybe some cache problem occurred. 如果存在此信息,则可能发生了某些缓存问题。 Then, try this: 然后,尝试以下操作:

Go to File -> Invalidate Caches / Restart... 转到文件->使缓存无效/重新启动...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM