Android Studio에서 기본 활동을 찾을 수 없습니다.
방금 Android Studio 0.2.8로 업그레이드했는데 실행 구성을 편집하려고 할 때 "Default Activity not found"라는 오류가 표시됩니다.
Android Studio를 시작할 때 "액세스는 이벤트 디스패치 스레드에서만 허용됩니다."라는 오류가 발생합니다.
내가 사용하는 활동은 조각 활동입니다.
지금까지 캐시를 재 구축하고 무효화 / 재시작을 시도했습니다. 둘 다 소용이 없었습니다.
문제를 해결하기 위해 무엇을 할 수 있는지 알려주세요.
Android Studio에서 프로젝트를 마우스 오른쪽 버튼으로 클릭하고 Open Module Settings를 선택 합니다 . 그런 다음 모듈 의 소스 탭으로 이동 하여 src 폴더를 찾아 마우스 오른쪽 버튼으로 클릭하고 소스 (파란색) 로 표시합니다 .
편집 : Android Studio의 최신 버전에는 소스 탭이 없지만 대신 build.gradle 파일을 편집 할 수 있습니다 . https://stackoverflow.com/a/22028681/1101730 (조쉬 주석에 감사드립니다)
ACTION_MAIN
주요 활동 에 인 텐트 필터를 추가 했습니까 ? 이것을 추가하지 않으면 Android는 어떤 활동을 기본 활동으로 시작할지 알 수 없습니다.
전의:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="com.package.name.MyActivity"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
프로젝트를 Android Studio로 가져 오는 동안 동일한 문제가 발생했습니다. 프로젝트가 현재 내 컴퓨터에 설치된 것보다 이전 버전의 Android Studio에서 개발 되었기 때문일 수 있습니다.
해결 된 것은 단순히 다음을 선택하는 것입니다.
File -> Invalidate Caches / Restart...
다음을 선택 Invalidate and Restart
합니다.
탭이없고 빈 활동으로 시작한 경우 이것을 시도하십시오. 다음은 샘플 코드 예입니다.
<application android:label="@string/app_name">
<activity android:name=".HelloActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
이제 AndroidManifest.xml 파일로 이동하십시오. 다음으로이 코드에서 인 텐트 필터를 복사합니다. 매니페스트 파일을 정말 잘보고 위 코드의 정확한 위치에 인 텐트 필터를 붙여 넣으십시오. (매니페스트의 .yourActivityName> 부분 뒤에 있습니다.) 도움이 되었기를 바랍니다.
"Open Module Settings (모듈 설정 열기)"를 클릭했을 때 "Source"탭이 없었습니다. Android Studio의 최신 버전 (0.8.14에 있습니다)에서 제거 되었기 때문이라고 생각합니다. 그래서 대신 이렇게해야했습니다.
블록 build.gradle
안의 파일에 다음 행을 추가하십시오 android { ... }
.
android { ... sourceSets { main.java.srcDirs += 'src/main/<YOUR DIRECTORY>' } }
파일을 편집 한 후 Tools> Android> Sync Project with Gradle Files를 클릭 합니다.
실행 한 후에도 실행 구성을 편집하려고 할 때 "기본 활동을 찾을 수 없음"이라는 오류가 계속 발생하는 경우 :
캐시를 무효화하고 다시 시작합니다 .
그런 다음 Settings / Preferences 폴더를 삭제 해보십시오.
/< USER_HOME_DIR >/.AndroidStudioPreview3.2
또는 Mac :
/Users/<USER_NAME>/Library/Preferences/.AndroidStudioPreview3.2
다음은 나를 위해 트릭을했습니다. 에서 실행 -> 편집 구성 .
이것은 내가 매니페스트의 경로를 대문자로했기 때문에 나에게 일어났습니다. 변경됨 :
<intent-filter>
<action android:name="ANDROID.INTENT.ACTION.MAIN"/>
<category android:name="ANDROID.INTENT.CATEGORY.LAUNCHER"/>
</intent-filter>
...에
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
그리고 그것은 수정되었습니다
Android Studio 1.5.1에서 동일한 오류가 발생했습니다. 문제의 원인을 찾았습니다. 원인이 사람의 실수인지 IDE 동작의 이상한 결함인지 확실하지 않지만이 주제에 대한 기존 StackOverflow 질문은 이것에 대해 아무것도 보여주지 않는 것 같았으므로 어쨌든 답변으로 게시 할 것이라고 생각했습니다.
나를 위해 팀 구성원 중 하나 또는 IDE 자체가 런처 활동 매니페스트 항목을 변경하여 다음과 같이 표시했습니다.
<activity
android:name="com.rhaebus.ui.activities.ActivitySplash"
android:launchMode="singleInstance"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<id android:name="android.intent.id.LAUNCHER" />
</intent-filter>
</activity>
실제로는 다음과 같아야합니다.
<activity android:name="com.rhaebus.ui.activities.ActivitySplash"
android:launchMode="singleInstance"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <!-- Change Here -->
</intent-filter>
</activity>
따라서 매니페스트에서 런처 활동의 형식을 두 배, 세 배, 네 배로 확인하면 시간을 절약 할 수 있습니다.
도움이 되었기를 바랍니다.
편집 : 나는 사람들이 모듈의 구성 옵션 내에서 실행기 활동을 수동으로 선택하도록 제안하는 답변을 사용하지 말 것을 강력히 제안합니다. 이로 인해 응용 프로그램이 삼성 Galaxy S5의 설치된 앱 목록에 더 이상 표시되지 않기 때문입니다. 네오와 삼성 갤럭시 S6 (적어도 나에게는).
매니페스트에서 패키지 이름이 주요 활동과 동일한 지 확인하세요.
오늘도 같은 문제가 발생하여 여기에서 답변을 살펴 보았습니다.
For me the difference was that yesterday it worked fine, so I figured it could not really be a configuration issue, neither configuration nor Version of Android Studio changed.
Fortunately, I tried a restart of Android Studio before trying any of the other answers, and luckily that solved the issue.
So for all people out there who run into this: first thing to try is to restart Android Studio and only if that does not solve the issue try the other answers here.
In Android Studio switch to Project perspective (not Android perspective).
Make sure that your project follows the gradle plugin's default structure (i.e. project_dir/app/src/main/java...)
Delete all build folders and subfolders that you see.
In the toolbar click Build -> Clean Project, then Build -> Rebuild Project.
Try to run the project.
You can get Android Studio not to complain by going to the "Edit Configurations" menu (tap "Shift" three times, type "Edit Configurations"), then change Launch Options > Launch to "Nothing".
I'll probably add a generic activity containing instructions, just to avoid any confusion.
- Right click on the project and choose Open Module Settings.
- Go to the Sources tab in your module.
- Find your src folder.
- Right click on it and mark it as Sources.
This solved the error in my case.
If you changed name of directories (class structure) for example com.dir.sample to com.dir.sample1, after that don't forget to change package com.dir.sample to com.dir.sample1.
Modify "Workspace.xml" (press Ctrl + Shft + R to search it)
Modify the activity name with package name
Make sure to change "name="USE_COMMAND_LINE" to value="false"
Reload the project
Done!
For those like me who were struggling to find the "Sources tab":
Here you have to mark your "src" folder in blue (first click in Mark as: Source, then in your src folder), and you're good to go.
There are two steps you can take:
- Go to configurations and enter the name of activity to be launched
- If it is still not working Disable Instant Run
I have tried all solutions, but not working at all. than I have tried to disable Instant run in my android studio.
Go to Android Studio Settings or Preferences (for MAC) -> Build,Execution,Deployment -> Instant Run.
uncheck the Instant run functionality and than after click sync project with gradle files from file menu
now run your build...
In some case you can have model with some category
field, if you will refactor it in all places, it may refactor it in manifest file and then and the tag xml will became invalid.
- In Android Studio
- Go to edit Configuration .
- Select the app.
- choose the lunch Activity path.
apply, OK.
Thanks!!
참고URL : https://stackoverflow.com/questions/18828654/default-activity-not-found-in-android-studio
'IT박스' 카테고리의 다른 글
불변 클래스? (0) | 2020.10.05 |
---|---|
JFrame의 닫기 버튼 클릭 이벤트를 캡처하는 방법은 무엇입니까? (0) | 2020.10.05 |
null이 매개 변수를 캐스팅하는 이유는 무엇입니까? (0) | 2020.10.05 |
Visual Studio 2005에서 Google C ++ 테스트 프레임 워크 (gtest)를 설정하는 방법 (0) | 2020.10.05 |
MySQL-하나의 INSERT 문에 몇 개의 행을 삽입 할 수 있습니까? (0) | 2020.10.05 |