'Error type 3 Error: Activity class {} does not exist' 오류 수정하기
Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.
Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.
아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.
Error type 3 Error: Activity class {} does not exist
에러 유형 3 오류: 액티비티 클래스 {}가 존재하지 않습니다
문제 내용
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:
IntelliJ에서 만든 안드로이드 프로젝트를 Android Studio 0.4.0으로 성공적으로 가져왔습니다. 매니페스트 파일을 변경하지 않으면 완벽하게 작동합니다. 그러나 런처 액티비티를 변경하려고하면 다음 오류가 발생합니다.
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:
실행 설정:
높은 점수를 받은 Solution
I faced a similar problem after refactoring.
This is what i did to resolve this issue:
리팩토링 후에 비슷한 문제가 발생했습니다.
이 문제를 해결하기 위해 내가 한 것은 다음과 같습니다:
- Cleaned the Project
- Deleted the
Build
directory - Restarted Android Studio
- Rebuild the Project
- Run
- Optionally (Go to the files menu on android, click on "Invalidate Caches / Restart..." uninstall the app on your phone and try again)
1. 저는 프로젝트를 청소(Clean)하고
2. Build 디렉토리를 삭제한 후
3. Android Studio를 재시작하고
4. 프로젝트를 다시 빌드(rebuild)했습니다.
5. 그런 다음 실행했습니다.
6. 만약 이 방법이 도움이 되지 않는다면 안드로이드의 파일 메뉴에서 "캐시 무효화 / 재시작..."을 선택하고 핸드폰에서 앱을 삭제한 후 다시 시도할 수 있습니다.
And everything worked fine!
I think the key is to restart your IDE.
그리고 모든 것이 잘 작동했습니다! 제 생각에는 IDE를 다시 시작하는 것이 핵심입니다.
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.
수정 1: 만약 위의 단계가 동작하지 않는다면, @Yasitha가 가리키듯이 Gradle 캐시를 삭제하는 것이 해결책인 것 같습니다.
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.
수정 2: 아래 댓글에서 몇몇 사용자들이 제안한대로, 때로는 기기에서 앱을 완전히 제거하고 다시 설치하면 문제가 해결될 수 있습니다. 터미널에서 adb uninstall 을 입력하여 기기에서 앱을 완전히 제거할 수 있습니다.
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 3 압히셋의 답변에서 언급했듯이, 기기에 여러 사용자가 설정되어 있는 경우 앱을 삭제해보는 것도 시도해 볼만합니다. 단순히 모바일 설정 > 앱 > [당신의 앱] > 기타 > 모든 사용자에게 앱 삭제로 이동합니다.
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.
편집 4 Yassin Ajdi가 언급한 대로, uninstallAll Gradle 작업을 실행하는 것도 문제를 해결할 수 있습니다. Gradle>Tasks>Install>uninstallAll로 이동하여 작업을 수행할 수 있습니다.
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 이상을 실행할 때, 기본적으로 활성화되어 있는 Instant Run 옵션을 설정해 놓은 경우에도 이 문제가 발생할 수 있습니다.
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 옵션으로 이동하여 Instant Run을 찾아 해당 화면에서 첫 번째 확인란을 체크 해제하면 됩니다.
Anyway that fixed it for me. Originally pointed out by user @yusufonder. I discovered this was the issue since gradle install still worked.
어쨌든 그것은 내 문제를 해결해주었습니다. 처음으로 @yusufonder 사용자가 지적했던 대로였습니다. Gradle 설치는 여전히 작동했기 때문에 이 문제가 Instant Run 설정에서 발생한 문제임을 발견했습니다.
가장 최근 달린 Solution
Try this from terminal
터미널에서 다음을 시도해보세요.
gradlew uninstallAll
This will uninstall all the debug, release, apks of all the versions of your app. And re-install the application
이것은 당신의 앱의 모든 버전의 디버그, 릴리스 및 apk를 제거하고 앱을 다시 설치할 것입니다.
출처 : https://stackoverflow.com/questions/20915266/error-type-3-error-activity-class-does-not-exist