Yiannr
Yiannr

Reputation: 1130

Session 'app': Error Launching activity

After the Android Studio 2.0 update while the gradle build finishes I get this :

Session 'app': Error Launching activity .

It prevents the app from starting but it's installed in my emulator. This is what comes up in the Run tab :

Unexpected error while executing: am start -n "com.example.user.ypologismosmoriwn/com.example.user.ypologismosmoriwn.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Error while Launching activity

Here is the code:

package com.example.user.ypologismosmoriwn;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

It's just an empty Activity,nothing added

and the XML code is just a Relative Layout with 4 Texts and 3 Check Boxes

This is the logcat i am getting

Thanks anyone who is willing to help

Upvotes: 106

Views: 168496

Answers (30)

spiraldev
spiraldev

Reputation: 171

None of the existing answers helped me as I had the same app installed in my other profile. Solution -

  1. Switch to the other profile
  2. Uninstall the app from 2nd profile
  3. Switch back

Upvotes: 1

GS Nayma
GS Nayma

Reputation: 1835

My Answer is specifically for Redmi/Mi Phone users. I faced this issue multiple times.

Sometimes we uninstall the app but it is not completely uninstalled but app will not display on screen and also it will not be listed in Settings -> Apps.

After checking multiple answers, What worked for me is below command

Go to Android Studio and click on Terminal tab in bottom of Android Studio. Connect your device, once adb detects your device, Run this command and try again to Run your application. Hope it will help.

adb uninstall com.shyam.smsapp

com.shyam.smsapp replace with your application package name

Upvotes: 0

EdgeDev
EdgeDev

Reputation: 2486

If you are using Android 7.0 and above it is likely that the app was installed in two places (Guest and Admin) and you only Uninstalled it for only one user and that is causing problems.

To solve that, go to: Settings -> Apps & Notifications -> See all Apps -> find the app you are trying to install.

enter image description here enter image description here

Then click the menu on the top right corner and select Uninstall for all users

enter image description here

Run Your App from Android Studio it should work.

Upvotes: 54

Mohammad Abu Hmead
Mohammad Abu Hmead

Reputation: 621

The only one best Answer is to run uninstall command from adb and install the app again

C:\Users\YourUser\AppData\Local\Android\sdk\platform-tools>adb uninstall applicationId

applicationId: from gradle module file

Upvotes: 0

Rafa
Rafa

Reputation: 21

Clearing the device data worked for me...

Close your emulator

Go to AVD Manager

Under "Actions" select "Wipe Data" (for the device your intend to use)

Then run your app again!

Hope this helps...

Upvotes: 0

adray
adray

Reputation: 1448

Adb also throws this error if applicationId, package of launching activity or module name contains error substring

Upvotes: 1

Nick
Nick

Reputation: 1634

I also faced this issue after I updated to AS2.0. I found that it is because of the instant run enabled. So my solution is to disable the "instant run". and it worked. To disable "instant run", you can go to Preference Dialog ( May be Setting dialog on Windows), then select Build, Execution, Deployment > Instant Run, and uncheck all the checkbox to disable Instant Run.

This is my temporary solution and it may help you. Later, I'll find a better way to this issue.


update by 2016/06/06

A better solution instead of disabling instant run. Remove the .idea folder and .gradle folder, then click button Sync Project with Gradle Files (or through the menu File -> Sync Project with Gradle Files), after this process finished, you are able to run your app as normal.

Good Luck~

Upvotes: 138

VIVEK CHOUDHARY
VIVEK CHOUDHARY

Reputation: 546

Sometimes when you uninstall the application from android device it does not get uninstalled completely. It goes to disabled state. To fix this, Go to Settings -> Apps -> Disabled Apps -> Select your app and uninstall.

Then go to android studio and run the app. The isssue is resolved.

Upvotes: 0

kiran puppala
kiran puppala

Reputation: 787

Just run adb uninstall <package name> in your terminal and reinstall the app again.

Hope it helps.

Upvotes: 3

Gilad Levinson
Gilad Levinson

Reputation: 234

I had the same error as in the headline. after I changed the version name and version code in the gradle, the sync happened and then it worked. so maybe even only sync can help sometimes.

Upvotes: 0

parse
parse

Reputation: 1922

I did all suggestions above, but they didn't work! I rebuilt the project, uninstalled the app from my real device, unplugged USB, then I run Android Studio and run the app on my real device and the issue was gone.

Hope this helps!

Upvotes: 0

UzumakiL
UzumakiL

Reputation: 403

OK already so many possible solutions for this problem, if none of those works then try this.

I faced this problem when I first uninstalled my app then tried reinstalling from ADB. But then after trying these many solutions, I realized that uninstalling app nowadays does not really uninstall it. It just disables it for few days so that it can be enabled in case you change your mind.

Now I am not sure whether its done by LG or Native Android Nougat.

I just went in Settings-> apps-> my-app and uninstalled it completely. After that from Android studio I am able to install the app again properly without this error.

Upvotes: 1

elliptic1
elliptic1

Reputation: 1752

For me the problem was that the app I was trying to launch was already installed under a different user account on my phone. I saw this when I went to Settings->apps looking to uninstall it. I switched to the other user, uninstalled it, came back to the original user, and was able to install and launch the app from Android Studio with no more problems.

Upvotes: 7

Hatim
Hatim

Reputation: 1522

I got the same error. This issue was caused by uninstalling the app from the device (uninstalled from only 1 user)

Solved by logging into the other user and uninstall the app from there.

and it solved.

Upvotes: 0

atish naik
atish naik

Reputation: 226

Disable "instant run", you can go to Preference Dialog ( May be Setting dialog on Windows), then select Build, Execution, Deployment > Instant Run, and uncheck all the checkbox to disable Instant Run.

And Reboot your Device this should make the thing work....instant run has a bug in Android studio 2+ This should do the magic

Upvotes: 0

Projgo
Projgo

Reputation: 73

I had same problem. I was using AVD with arm processor image and received this same message. The only way for me to make Android Studio 2.1.2 runs the app with instant run was change to an X86 processor image. The error was gone and ( until this moment) I think the emulator works faster than ARM emulated. My workstation configuration is Intel I5, 6Gb RAM. Maybe this helps until next fix.

Upvotes: 0

devDeejay
devDeejay

Reputation: 6059

Just disable Instant Run.

Go To File >> Settings >> Build, Execute, Deployment >> Instant Run

Uncheck The Box that says Enable instant run to hot swap code/resource changes on deploy

Re-run the emulator.

Upvotes: 1

Tirth Patel
Tirth Patel

Reputation: 5746

I tried, clean & rebuild project and Invalidate Cache & Restart also manually removed .gradle and .idea folders, but that didn't solved the issue.

I have 3 user acounts in my phone. So, I didn't select Uninstall for all users, and it only uninstall my app from first user account, but it was still there in guest and second user account.

So, I removed it from rest of the accounts and it solved my issue!!

Upvotes: 0

klenium
klenium

Reputation: 2617

Try reinstalling the app, this solved the error for me. The trick was that, I uninstalled my app, but Android didn't truly uninstall it. On my phone, there is a guest user (my sister uses it sometimes). If you uninstall the app from your main user, it will still be available on the phone, but only for the guest user. It looks like Android Studio can't handle this case. I guess it detects that the app is installed, so it will not be reinstalled again for the current user, hence the OS can't access and launch the activity. Nice bug, I'll report it.

Upvotes: 36

fathurzero
fathurzero

Reputation: 1496

Uninstall App on your real device or emulator. Then Run again. It's worked for me. I used Android Studio 2.3.3

Upvotes: 1

Sanjoy Kanrar
Sanjoy Kanrar

Reputation: 897

I had this error because of my stupidity. In the manifest.xml I have wrongly declared two Activity as Launcher. Make sure you have only one activity as Launcher.

    <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=".WelcomeActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Upvotes: 2

Hoque MD Zahidul
Hoque MD Zahidul

Reputation: 11989

I've fixed the issue using this solution.If you are running the application in USB device then close all the virtual device like : genymotion / virtual machine .

Upvotes: 1

user3329166
user3329166

Reputation: 126

I tried all suggested answers. I found out this is a hardware issue on Android N phone with studio 2.3 version. App launches fine on phones below version 7.

Upvotes: 1

Maggie
Maggie

Reputation: 51

it occured when I changed the applicationId in app gradle file. It works for me after I sync gradle.

Upvotes: 0

Kiryl Ivanou
Kiryl Ivanou

Reputation: 1043

I've fixed the issue (on my Anroid watch Moto 360) by uninstalling the app before installing from AS

Upvotes: 0

Muhammad Usman
Muhammad Usman

Reputation: 923

Just Run --> clean and rerun , In my case it helps. Prompts automatically like following message

would you uninstall already installed activity with same name

if activity is already installed first uninstall it and make project ready after installing app.

Upvotes: 2

Benson Macharia
Benson Macharia

Reputation: 1026

I was facing the same problem in android studio 2.1.2 but worked after selecting Build -> Clean Project or alternatively Run -> Clean and Rerun

Upvotes: 1

CodyF
CodyF

Reputation: 5227

Same issue, but for me problem was that Android Studio couldn't find my Default Activity. When I specified the intent filter to catch the MAIN action intent, I didn't specify the LAUNCHER category, and that caused the 'Error Launching activity' issue.

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />  <-- forgot
    </intent-filter>

Upvotes: 2

user5186466
user5186466

Reputation:

All answers did not work for me.This error raised when I was trying to rename the app package.I have ended up creating a new project with the new package name and move my files to the new one.

Upvotes: 0

Rahul
Rahul

Reputation: 337

This is issue with 2.0+ studio

Issue 206036: No local changes, not deploying APK

I found the nice workaround here just add -r flag here in edit configurations and also disabling instant

enter image description here

Waiting to get Instant run Feature run smoothly soon with no type 3 error more!!

Upvotes: 9

Related Questions