0

Am a newbie in android studio, I can't figure out how to stop this error even looking into other posts. I don't understand how to add activity in the manifest. Here is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.drpg.dungeonkeys"
    android:versionCode="4"
    android:versionName="Beta.4.44" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <service android:name=".DungeonKey"
            android:label="@string/dungeon_key"
            android:permission="android.permission.BIND_INPUT_METHOD"
            >
            <meta-data android:name="android.view.im" android:resource="@xml/method"/>
            <intent-filter>
                <action android:name="android.view.InputMethod" />
            </intent-filter>            
        </service>

    </application>

</manifest>
John Joe
  • 12,412
  • 16
  • 70
  • 135

5 Answers5

1

Your manifest need to look something like this :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="[YOUR_PACKAGE]">

    <!-- Differents permissions you need -->

    <application
    ... >
        <!-- Here default activity -->
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!-- Other activity declarations -->
        <activity
            android:name=".OtherActivity" />

        <!-- If you have some services, write them here -->
        <service
            android:name=".MyService"
            android:exported="false"/>
    </application>
</manifest>
Skyle
  • 211
  • 2
  • 11
  • So the `` in the manifest is not required? imported from eclipse ADT –  Feb 07 '18 at 08:56
  • Of course if you have services, put them. Pls look edited answer. Here in your first post, you just missed to add with the intent filter that specifiy it's the first activity of your app to launch. – Skyle Feb 07 '18 at 09:52
0

You don't have <activity> tag in your manifest file.

Simplest version is :

<activity
     android:name="com.drpg.dungeonkeys.ActivityName"
     android:label="@string/app_name" />

Check out this official tutorial : https://developer.android.com/training/basics/firstapp/creating-project.html

Here you have detailed info about <activity> tag : https://developer.android.com/guide/topics/manifest/activity-element.html

0

If you look at the android documentation's page for the app manifest, you will see that you need to declare all your activities there. The following code comes directly from that page, I removed some of it to shorten the answer.

<manifest>

    <application>

        <activity
            android:name="com.example.MyActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>
Raul Sauco
  • 2,645
  • 3
  • 19
  • 22
0

Multiple ways to add activities in the Manifest file.

the intent filter is not a necessary tag for all activities, it is optional.

Add Activity in application tag in your manifest:

<!-- Main Activity-->
    <activity android:name="YourActivityName" >
        <intent-filter>
      <!-- MAIN represents that it is the Main Activity-->
            <action android:name="android.intent.action.MAIN" />
      <!-- Launcher Denotes that it will be the first launching activity-->
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
 <!--Add Other activities like this-->
    <activity android:name="YourActivityName2" >
 <!--Default Intent Filter-->
        <intent-filter>
            <action android:name="android.intent.action.DEFAULT" />
        </intent-filter>
    </activity>
 <!--OR Other activities like this And  intent filter is not necessary in other activites-->
    <activity android:name="YourActivityName3" >
    </activity>
 <!--OR Add Other activities like this-->
    <activity android:name="YourActivityName4" />
Zara Khan
  • 134
  • 2
  • 16
0

You have forgotten to declare launcher Activity to your manifests

<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

declare your activity as the launcher which you want to start first.