Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 423
Yiannr Avatar asked Apr 10 '16 13:04

Yiannr


2 Answers

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~

like image 153
Nick Avatar answered Oct 09 '22 07:10

Nick


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.

like image 25
LekeOpe Avatar answered Oct 09 '22 08:10

LekeOpe