user3277633
user3277633

Reputation: 1923

Android app not showing on my device. No Launcher Activity Found

I am simply following the Android Developer training guide, and I am already running into troubles on the second step.

I followed the guide (I don't even have to do anything..) and clicked on Run, selected my Galaxy S4 from the screen, and clicked okay. I get the following error

[2014-07-06 19:56:27 - MyFirstApp] Android Launch!
[2014-07-06 19:56:27 - MyFirstApp] adb is running normally.
[2014-07-06 19:56:27 - MyFirstApp] No Launcher activity found!
[2014-07-06 19:56:27 - MyFirstApp] The launch will only sync the application package on the device!
[2014-07-06 19:56:27 - MyFirstApp] Performing sync
[2014-07-06 19:56:27 - MyFirstApp] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2014-07-06 19:56:31 - MyFirstApp] Application already deployed. No need to reinstall.
[2014-07-06 19:56:31 - MyFirstApp] \MyFirstApp\bin\MyFirstApp.apk installed on device
[2014-07-06 19:56:31 - MyFirstApp] Done!

I honestly have no idea what I am doing wrong, as I have absolutely no experiences with android.

The only thing that is different is in the tutorial their targetSdkVersion is 19, but I am using 21

The following is my AndroidManefiest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myfirstapp"
    android:versionCode="1"
    android:versionName="1.0" >

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

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

</manifest>

Upvotes: 0

Views: 2444

Answers (2)

JaskeyLam
JaskeyLam

Reputation: 15755

Put the following intent-filter for your activity to be launched.

 <activity class=".YourActivity" android:label="your activity label">
       <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
 </activity>   

{ action=android.app.action.MAIN } matches all of the activities that can be used as top-level entry points into an application.

{ action=android.app.action.MAIN, category=android.app.category.LAUNCHER } is the actual intent used by the Launcher to populate its top-level list.

Also, please refer to Intent

Upvotes: 1

Murillo Ferreira
Murillo Ferreira

Reputation: 1433

You forgot to declare your activity to your Manifest.xml.

Everytime you create an activity (blablabla class extends Activity) you have to declare it to your Android Manifest.xml, in order to de device be able to track your App's life cicle.

What we call Activity is a class that provide information to host a window, the class should extends Activity, all of this classes must be declared on the Manifest.xml file as below:

<application>
    ...

    <activity
            android:name="com.yourpackage.ClassName">

    </activity>

</application>

Probably your activity class is called MainActivity, you just have to add this to your code, between <application> </application> tag:

    <activity
        android:name="com.example.myfirstapp.MainActivity"
        android:label="@string/app_name"> <!-- This is the text that will appear on your action bar -->

        <intent-filter>

            <action android:name="android.intent.action.MAIN" />

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

        </intent-filter>

    </activity>

The <intent-filter> tells to android that this class is the "main entrance", the first activity that need to be loaded to your app be launched, only the first activity need the <intent-filter> tag, the others just need the fist example I gave.

If you are starting with Android development, I recommend you to read about ActionBar and What to do when the device is rotated

This and this may help you in the future.

Good coding :)

Upvotes: 3

Related Questions