끄적끄적

[Android Studio] have you declared this activity in your AndroidManifest.xml?

날아가는기억잡기 2020. 3. 30. 15:42

 Activity를 추가하고 사용하려면 "AndroidManifest.xml"파일에 이를 선언해야한다. 이를 선언하지 않으면 have you declared this activity in your AndroidManifest.xml? 와 같은 오류가 발생하게 된다. 

 새로운 Activity가 SubActivity라고 하면 19번째 줄과 같은 코드를 추가하면 해결된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?xml version="1.0" encoding="utf-8"?>
 
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SubActivity" />
    </application>
 
</manifest>
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs