Android Studio error解決: Error while executing:am start Error type 3 Activity class does not exist

環境:MacOS、Android Studio 3.5、Huawei P20 Pro、Android 9 (環境跟本題關係不大)

背景:通過 Android Studio在手機上安裝應用之後,手動在手機上卸載了該app,之後就再也安裝不上了。手機端雖然顯示安裝成功,但是“打開”按鈕是灰色的,並且桌面上也沒有應用圖標,如下:

Studio端報錯

Error while executing: am start -n "xxx/xxx" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=xxx/.xxx }
Error type 3
Error: Activity class {xxx/xxx.xxx} does not exist.

 

解決方法

常用方法有clean工程,重新build; 使用adb指令卸載apk; 運氣好的話基本就解決了,如下截圖:

(圖截自騷劍客的博客https://blog.csdn.net/qq_30552993/article/details/74007090

試了這些方法都不行,也有說可以禁用 “Instant Run”試試,不過Android Studio 3.5及之後的版本“Instant Run”已經被新引入的 “Apply Changes”取代了,沒有嘗試。

谷歌上搜到一個討論,一個答主說“可能的原因是因爲這個應用仍然存在在這個設備上的另一個賬戶上”,具體討論可以看這裏:https://stackoverflow.com/questions/46888298/activity-class-does-not-exist-error-type-3

然後想到華爲手機有一個隱私空間功能,相當於手機上存在另外一個系統,進入這個系統發現剛纔安裝的app果然還在裏邊,把這個系統中的app也卸載之後,再運行Android Studio,已經可以成功導入app了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章