今天真机运行项目发现报了这个错误:

$ adb shell am start -n "com.app.yxsoft/com.baby.grow.ui.sys.SplashActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHERError while executing: am start -n "com.app.yxsoft/com.baby.grow.ui.sys.SplashActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHERStarting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.app.yxsoft/com.baby.grow.ui.sys.SplashActivity }Error type 3Error: Activity class {com.app.yxsoft/com.baby.grow.ui.sys.SplashActivity} does not exist.Error while Launching activity

原因

手动卸载了手机上的App,然后点击Android Studio的运行按钮就出现了上面的bug.死活运行不起来!   

根据错误信息来看,Android studio仍然启动的是上个包名下的Activity,也就说明Android studio缓存了启动信息,我们需要清除它。

没有卸载干净

注意:如果你是华为手机,也有可能是隐私空间造成的该问题,两个空间都安装了app,这里特别感谢本文评论中提出该问题的朋友

Android Studio报错Error while executing: am start -n “com.lzy.app/com.lzy.app.Splash_第1张图片

手动卸载app没有卸载干净,就用了adb uninstall packageName命令运行了一下,发现果然是如此:

Android Studio报错Error while executing: am start -n “com.lzy.app/com.lzy.app.Splash_第2张图片

再次点击Android Studio的运行按钮,成功安装运行。

方法二:

修改代码之后,点击运行,AndroidStudio没有进行重新编译,而是提示no changes to deploy,然后启动修改前的那个APP,代码修改完全没用。这个问题初步判断是由于AndroidStudio的Instant run功能出错导致的。目前只能在settings->Build,Execution,Deployment->Instant Run中将Enable Instant Run to hot swap code/resource changes on deploy选项的勾点掉。这是默认启用的。点掉之后就正常了,每次点击运行都会重新安装APP。

自己试了一下,没找到settings->Build,Execution,Deployment->Instant Run

方法三:

找到File-> Invalidate Caches / Restart ,重启Android Studio,重启完成后运行APP就可以正常启动了.。

完!!!

 

 

 

 

 

 

更多相关文章

  1. Android标题栏最右边添加按钮
  2. Android 监听按钮点击事件的三种方式(1:匿名内部类;2:外部类;3:接口方
  3. android 自定义返回按钮
  4. android 日期按钮实现
  5. 如何实现5个按钮成梅花状排列,并整体居中?
  6. Android 圆形按钮实现
  7. Android 监听EditText是否为空,控制按钮是否可用
  8. Android点击返回按钮两次退出系统

随机推荐

  1. android BadTokenException之token is no
  2. 2011.08.12(2)——— android MediaPlayer
  3. android-GooglePlay安装来源追踪PlayInst
  4. 在下方的tab页
  5. GoogleAndroid常用的Android常量
  6. Android(安卓)Media Framework 总纲
  7. android截屏代码:C++实现
  8. 使用Android(安卓)Studio创建Android(安
  9. android开发--RelativeLayout用到的一些
  10. Android(安卓)获取基站信息