3

I am working on an app which does not have any launcher activity. But when I try to install that app from Android Studio's Run icon, it says, 'Error running XYZApp: Default Activity not found'

I did not see such issue ever in Eclipse.

Can anyone help to fix this issue? How can I install my app in device which doesn't have any Launcher Activity.

AndroDev
  • 3,236
  • 8
  • 35
  • 49

4 Answers4

2

Edit your configuration, and there in 'Launch' select 'Nothing' (or something else, what you want to run)

Tomasz Czura
  • 2,414
  • 1
  • 14
  • 18
1

You must be missing the action and category for your main activity in AndroidManifest file

just add the intent filers in your activity as below :

<activity
        android:name="com.example.MainActivity"
        android:label="XYZApp"
        android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
shadygoneinsane
  • 2,226
  • 1
  • 24
  • 47
  • Yes. I did not add action and category for my main category as there is no main activity. As I mentioned, my app does not have any launcher activity and won't be launched by user from app drawer. My problem was how to install app when there is not launcher activity in app. – AndroDev Dec 29 '16 at 11:17
0

If you are upgrading from Eclipse to Android Studio you might need to refresh the cache for Android Studio and restart IDE.

Follow the following steps:

File -> Invalidate Caches / Restart...

You also need to mention the Activity in the Manifest file of your Android project. You can use following code to do so: Here MainActivity will start when your app launches on the android device.

<context android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</context>
Karan Sharma
  • 2,353
  • 4
  • 28
  • 46
  • Thank you for your ans. But this was not the case with me. In my app, I am not having any launcher activity(no launcher intent). Due to this it was not able to install app in the device. Now issue is fixed. Pls check my accepted ans. – AndroDev Dec 29 '16 at 11:12
0

Run -> Edit Configurations.

On 'Launch' select the activity you want to start.

enter image description here

Manza
  • 3,427
  • 4
  • 36
  • 57
  • Thank You for your answer. In my case, I have to select nothing to install my app in device. Please check my accepted ans. – AndroDev Dec 29 '16 at 11:13